<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="embedded system engineer">
<meta property="og:type" content="website">
<meta property="og:title" content="Jason Lin">
<meta property="og:url" content="http://ideask.cf/index.html">
<meta property="og:site_name" content="Jason Lin">
<meta property="og:description" content="embedded system engineer">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Jason Lin">
<meta name="twitter:description" content="embedded system engineer">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://ideask.cf/"/>





  <title> Jason Lin </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Jason Lin</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
    
      <p class="site-subtitle">Jason's Blog</p>
    
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/04/27/bbb-build-can/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/04/27/bbb-build-can/" itemprop="url">
                  BBB添加CAN支持
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-04-27T17:56:10+08:00">
                2017-04-27
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-04-27
			17:56:10
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/BeagleBoneBlack/" itemprop="url" rel="index">
                    <span itemprop="name">BeagleBoneBlack</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/27/bbb-build-can/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/04/27/bbb-build-can/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>A few months back I got hold of my first BeagleBone Black (BBB) with the intention of installing it in my car as a trackday data logger. First step in this endeavor was to get the CANBus working. I wrote this up here, but I’m shutting down that (poorly designed) site and have come up with a better way of enabling CAN so here goes.</p>
<p>First up, I’m assuming you are either running the latest Angstrom image (see here), or Ubuntu with the patched device tree compiler (see here). This ensures you have a device tree compiler which is capable of compiling overlays. So with that out of the way…</p>
<p>Enabling DCAN1</p>
<p>Update 26th August 2013: This original post focused on enabling dcan1, as these pins are available by default. If you’d like to enable dcan0 (At the expense of i2c2, possibly breaking any capes you have plugged in!), skip to the bottom of the post</p>
<p>To enable CAN (specifically dcan1), we need to write a device tree overlay which will enable the device and set the pin muxing. For those of you who just want the answer, here’s the overlay.</p>
<p>BB-DCAN1-00A0.dts</p>
<pre><code class="bash">/dts-v1/;
/plugin/;

/ {
    compatible = <span class="string">"ti,beaglebone"</span>, <span class="string">"ti,beaglebone-black"</span>;

    /* identification */
    part-number = <span class="string">"dcan1pinmux"</span>;

    fragment@0 {
        target = &lt;&amp;am33xx_pinmux&gt;;
        __overlay__ {
            dcan1_pins_s0: dcan1_pins_s0 {
                pinctrl-single,pins = &lt;
                    0x180 0x12  /* d_can1_tx, SLEWCTRL_FAST | INPUT_PULLUP | MODE2 */
                    0x184 0x32  /* d_can1_rx, SLEWCTRL_FAST | RECV_ENABLE | INPUT_PULLUP | MODE2 */
                &gt;;
            };
        };
    };

    fragment@1 {
        target = &lt;&amp;dcan1&gt;;
        __overlay__ {
             <span class="comment">#address-cells = &lt;1&gt;;</span>
             <span class="comment">#size-cells = &lt;0&gt;;</span>

             status = <span class="string">"okay"</span>;
             pinctrl-names = <span class="string">"default"</span>;
             pinctrl-0 = &lt;&amp;dcan1_pins_s0&gt;;
        };
    };
};
</code></pre>
<p>There are two important parts to the overlay, fragment@0 and fragment@1. We’ll look at each of those in turn.</p>
<p>fragment@0 is responsible for setting the pin mux. The two lines of hex (15-16) represent pairs of ‘pin’ register and ‘mode’ value.</p>
<p>Update 20th August 2013: I’ve created a spreadsheet to simplify the determination of register offset and mode values so you no longer have to dig through datasheets. The dcan1 signals can be found on pins P9 _24 and P9_26, both Mode 2. Use the register value worksheet to determine the correct pinmux values (Fast slew,  input for rx/output for tx, pull up, mode 2).</p>
<p>To find the correct register you first need to find out the name of the pins from the BBB SRM. Referring to Table 11 in the SRM, you can find the dcan1 signals are exposed on pins 24 (UART1_TXD) and 26 (UART1_RXD).</p>
<p>Now, diving in to the AM3359 Technical Reference Manual. In Table 9-10 (on page 759!) you can find the two registers conf_uart1_txd (0x980) and conf_uart1_rxd (0x984). These pin configuration registers start at 0x800, therefore the offset values are 0x180 and 0x184 respectively.</p>
<p>The detail of these registers can be found in Section 9.3.51, letting you calculate the correct values for dcan1.</p>
<p>Pin    Slew Rate    Input    Pull Up    Pull Up    Mode    Mode    Mode    In Hex</p>
<pre><code class="bash">d_can1_tx (0x180)    0    0    1    0    0    1    0    0x12
d_can1_rx (0x184)    0    1    1    0    0    1    0    0x32
</code></pre>
<p>That’s it for fragment@0, on to fragment@1. This section enables the CAN device. Firstly, on line 23, we identify the device we want to enable as dcan1. Then we specify that we want the device enabled by setting it’s status to “okay” on line 28. Finally, we associate the pin mux created in fragment@0 with the device, line 30.</p>
<p>To compile this overlay, save it as BB-DCAN1-00A0.dts (the dts extension referring to a device tree source file). Then execute the following command.</p>
<pre><code class="bash">dtc -O dtb -o BB-DCAN1-00A0.dtbo -b 0 -@ BB-DCAN1-00A0.dts
</code></pre>
<p>This will create the overlay binary BB-DCAN1-00A0.dtbo. If you get an error about the -@ option being unrecognised then you are likely on Ubuntu without the patched version of dtc (see here).</p>
<p>To use the overlay simply copy it to /lib/firmware</p>
<pre><code class="bash">sudo cp BB-DCAN1-00A0.dtbo /lib/firmware
</code></pre>
<p>And execute the following (note you must be logged in as root to do this, sudo will not work!)</p>
<pre><code class="bash"><span class="built_in">echo</span> BB-DCAN1 &gt; /sys/devices/bone_capemgr.*/slots
</code></pre>
<p>Check with dmesg to see if this worked, you should see something like this</p>
<pre><code class="bash">dmesg | tail -n15
[   17.878323] init: plymouth-stop pre-start process (796) terminated with status 1
[  283.946706] bone-capemgr bone_capemgr.8: part_number <span class="string">'BB-DCAN1'</span>, version <span class="string">'N/A'</span>
[  283.946892] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: generic override</span>
[  283.946944] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 9
[  283.946996] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: 'Override Board Name,00A0,Override Manuf,BB-DCAN1'</span>
[  283.947270] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: Requesting part number/version based 'BB-DCAN1-00A0.dtbo</span>
[  283.947323] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: Requesting firmware 'BB-DCAN1-00A0.dtbo' for board-name 'Override Board Name', version '00A0'</span>
[  283.951368] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: dtbo 'BB-DCAN1-00A0.dtbo' loaded; converting to live tree</span>
[  283.952035] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: #2 overlays</span>
[  283.953133] platform 481d0000.d_can: <span class="built_in">alias</span> fck already exists
[  283.962225] bone-capemgr bone_capemgr.8: slot <span class="comment">#9: Applied #2 overlays.</span>
[  284.034183] CAN device driver interface
[  284.071999] c_can_platform 481d0000.d_can: invalid resource
[  284.078088] c_can_platform 481d0000.d_can: control memory is not used <span class="keyword">for</span> raminit
[  284.084553] c_can_platform 481d0000.d_can: c_can_platform device registered (regs=fa1d0000, irq=71)
If you have something to hook up to (don<span class="string">'t forget to go through a transceiver, or bad things will happen), you can test everything is up and working with can-utils. First, make sure you have all the relevant modules loaded.</span>
</code></pre>
<pre><code class="bash">sudo modprobe can
sudo modprobe can-dev
sudo modprobe can-raw
</code></pre>
<p>Get and build can-utils</p>
<pre><code class="bash">svn co svn://svn.berlios.de/socketcan/trunk
<span class="built_in">cd</span> trunk/can-utils/
make
</code></pre>
<p>Set up the bus speed and enable it</p>
<pre><code class="bash">sudo ip link <span class="built_in">set</span> can0 up <span class="built_in">type</span> can bitrate 500000
sudo ifconfig can0 up
</code></pre>
<p>Now you can use either cansend or candump to test your bus.</p>
<p>Unfortunately, I’ve discovered my car is more rust than chassis so the track days are going to have to wait. BBB has been repurposed to other projects, more details on these coming soon…</p>
<p>Enabling DCAN0</p>
<p>Update 26th August 2013: After the comment from Marco below, I’ve put this section in to enable DCAN0.</p>
<p>To enable dcan0, you’ll need an overlay similar to that for dcan1. Marco posted one below, but it seems the comment system strips angled brackets for fear of HTML tags, so here is one I made.</p>
<p>BB-DCAN0-00A0.dts</p>
<pre><code class="bash">/dts-v1/;
/plugin/;

/ {
    compatible = <span class="string">"ti,beaglebone"</span>, <span class="string">"ti,beaglebone-black"</span>;

    /* identification */
    part-number = <span class="string">"dcan0pinmux"</span>;

    fragment@0 {
        target = &lt;&amp;am33xx_pinmux&gt;;
        __overlay__ {
            dcan0_pins_s0: dcan0_pins_s0 {
                pinctrl-single,pins = &lt;
                    0x178 0x12  /* d_can0_tx, SLEWCTRL_FAST | INPUT_PULLUP | MODE2 */
                    0x17C 0x32  /* d_can0_rx, SLEWCTRL_FAST | RECV_ENABLE | INPUT_PULLUP | MODE2 */
                &gt;;
            };
        };
    };

    fragment@1 {
        target = &lt;&amp;dcan0&gt;;
        __overlay__ {
             <span class="comment">#address-cells = &lt;1&gt;;</span>
             <span class="comment">#size-cells = &lt;0&gt;;</span>

             status = <span class="string">"okay"</span>;
             pinctrl-names = <span class="string">"default"</span>;
             pinctrl-0 = &lt;&amp;dcan0_pins_s0&gt;;
        };
    };
};
</code></pre>
<p>We can build and install this in the same way</p>
<pre><code class="bash">dtc -O dtb -o BB-DCAN0-00A0.dtbo -b 0 -@ BB-DCAN0-00A0.dts
sudo cp BB-DCAN0-00A0.dtbo /lib/firmware
</code></pre>
<p>However, if you try to enable dcan0 now you will get an error about the i2c pins (see Marco’s comment). This is because the i2c2 pins are enabled by default and take precedence over any overlay. Before we continue I should mention that the i2c2 pins are used by the BBB to identify capes, and enable devices/pinmuxes appropriately, everything I do from here on is likely to stop any capes working!.</p>
<p>Another warning: This process involves modifying the default device tree binary. If you do this incorrectly, your BBB will not boot. If you’re messing with the eMMC image, I can’t guarantee it can be reflashed either (although I see no reason why it shouldn’t be possible). You’re following this guide at your own risk, if it breaks your BBB it’s not my fault! I do all my hacking on an Ubuntu flashed SD card, so if it goes wrong (and it often does!) I can stick the card in my PC and undo any changes. eMMC users, continue at your own risk…</p>
<p>Unfortunately, we can’t simply disable i2c2 with an overlay (I have tried, it crashed my BBB!). We also can’t switch off the i2c2 device, because it is used by bone_capemgr and disabling it seems to make /sys/devices/bone_capemgr.*/slots disappear, meaning we can’t enable overlays! So, my work around is simply to prevent the i2c2 device setting its pinmux and claiming the dcan0 pins. In this state, as far as bone_capemgr is concerned, the i2c2 pins are perpetually disconnected (but the device still exists in /dev/).</p>
<p>To stop i2c2 from setting its pinmux, we need to modify the default device tree binary, and to do this we need the source files. If you built your kernel from scratch you will have them lying around somewhere, but if not you can grab them from Derek Molloy’s git repository (Note, I’m assuming the 3.8.13 kernel here).</p>
<pre><code class="bash">git <span class="built_in">clone</span> https://github.com/derekmolloy/boneDeviceTree.git
<span class="built_in">cd</span> boneDeviceTree/DTSource3.8.13/
</code></pre>
<p>Open up am335x-bone-common.dtsi and go to line 401 (pass the -c flag to nano to show line numbers). This is the section concerning i2c2.</p>
<pre><code class="bash">nano -c am335x-bone-common.dtsi
</code></pre>
<p>am335x-bone-common.dtsi</p>
<pre><code class="bash">&amp;i2c2 {
    status = <span class="string">"okay"</span>;
    pinctrl-names = <span class="string">"default"</span>;
    pinctrl-0 = &lt;&amp;i2c2_pins&gt;;

    clock-frequency = &lt;100000&gt;;

    cape_eeprom0: cape_eeprom0@54 {
        compatible = <span class="string">"at,24c256"</span>;
        reg = &lt;0x54&gt;;
    };

    cape_eeprom1: cape_eeprom1@55 {
        compatible = <span class="string">"at,24c256"</span>;
        reg = &lt;0x55&gt;;
    };

    cape_eeprom2: cape_eeprom2@56 {
        compatible = <span class="string">"at,24c256"</span>;
        reg = &lt;0x56&gt;;
    };

    cape_eeprom3: cape_eeprom3@57 {
        compatible = <span class="string">"at,24c256"</span>;
        reg = &lt;0x57&gt;;
    };
};
</code></pre>
<p>To prevent the pinmux from being applied, simply comment out </p>
<p>am335x-bone-common.dtsi</p>
<p>//  pinctrl-0 = &lt;&amp;i2c2_pins&gt;;<br>Save and exit, then build with (note, you’re not building the file you just edited!)</p>
<pre><code class="bash">dtc -O dtb -o am335x-boneblack.dtb -b 0 -@ am335x-boneblack.dts
</code></pre>
<p>Before overwriting your default device tree binary, back it up</p>
<pre><code class="bash">sudo mv /boot/uboot/dtbs/am335x-boneblack.dtb /boot/uboot/dtbs/am335x-boneblack.orig.dtb
</code></pre>
<p>Now move your new binary in to place</p>
<p>sudo mv am335x-boneblack.dtb /boot/uboot/dtbs/<br>You’ll get an error about preserving permissions, you can safely ignore this.</p>
<p>Now reboot your BBB and the i2c2 pinmux will not be applied. Now you should be able to enable dcan0 in much the same way as dcan1. As root (not sudo!)</p>
<pre><code class="bash"><span class="built_in">echo</span> BB-DCAN0 &gt; /sys/devices/bone_capemgr.*/slots
</code></pre>
<p>Now grab can-utils and play around with the bus (see above for dcan1).</p>
<p>If you plan to use dcan0 and dcan1, I believe the device driver numbering is based on the order the devices are enabled. So enable dcan0 before dcan1 so that your calls to ip, ifconfig, candump, etc… all make sense!</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/04/27/bbb-build-spi/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/04/27/bbb-build-spi/" itemprop="url">
                  BBB添加SPI支持
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-04-27T17:55:58+08:00">
                2017-04-27
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-04-27
			17:55:58
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/BeagleBoneBlack/" itemprop="url" rel="index">
                    <span itemprop="name">BeagleBoneBlack</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/27/bbb-build-spi/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/04/27/bbb-build-spi/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>在3.2之前版本的内核里spi驱动要先注册spi_board_info结构体,然后匹配spi_master, 再创建spi_device. 创建完设备之后再到spi总线上寻找有没有同名的spi_driver. 如果有的话就调用spi_driver的probe函数. 在probe函数里register_chrdev/class_create/device_create, 创建chrdev然后通过fops里的函数来读写spi设备.<br>在新版的内核里推荐使用dts来描述设备信息, 并且先注册spi_master, 然后再创建设备, 最后跟platform总线上的driver的 .of_match_table成员里的元素匹配, 如果匹配成功就调用probe. 所以新版的内核里我们不需要再写spi_baord_info 和spi_register_board_info这样的代码了</p>
<p>折腾了一个星期的人表示看到上边这个画面简直泪如雨下.  下边我们就看如何在不修改一丁点内核代码的情况下让系统显示出这个画面.<br><img src="http://img.blog.csdn.net/20150723153952844" alt="这里写图片描述"><br>首先交代一下我使用的系统. 我使用的是TI最新板的sdk: ti-processor-sdk-Linux-am335x-evm-01.00.00.00-Linux-x86-Install.bin</p>
<pre><code class="bash">root@am335x-evm:~<span class="comment"># uname -a  </span>
Linux am335x-evm 3.14.26 <span class="comment">#22 Wed Jul 22 16:14:16 CST 2015 armv7l GNU/Linux</span>
</code></pre>
<p>我们先找到我们要修改的文件: am335x-boneblack.dts</p>
<p>(sdk)/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/arm/boot/dts/am335x-boneblack.dtb  </p>
<p>因为dts文件层层包含我们不容易搞清楚结构, 那还不如将dtb反编译回dts, 看看最终的dts文件.</p>
<pre><code class="bash">dtc -I dtb -O dts am335x-boneblack.dtb &gt; am335x-boneblack.dts
</code></pre>
<p>第一处修改:<br><img src="http://img.blog.csdn.net/20150723160658562" alt="这里写图片描述"></p>
<p>第二处修改:<br><img src="http://img.blog.csdn.net/20150723160803617" alt="这里写图片描述"></p>
<p>添加这两部分的代码, spi0_pins 和spi1_pins分别对应spi0和spi1引脚的配置, 关于引脚的配置值可以用TI官方的pinmux工具来生成.<br>第三处修改:<br><img src="http://img.blog.csdn.net/20150723161619530" alt="这里写图片描述"><br>spi@48030000 对应spi0<br>spi@481a0000 对应spi1<br>compatible = “ti,omap4-mcspi” 对应spi驱动底层 spi_master驱动(spi-omap2-mcspi.c)下 的platform_drvier里的 .of_match_table 成员.如果 .of_match_table 数组里有 “ti,omap4-mcspi” 那么就可以调用该platform_driver的probe函数.在spi_register_master中创建设备<br>compatible = “rohm,dh2228fv” 对应spi驱动上层 spi_driver (spidev.c)的 .of_match_table 成员. 如果 .of_match_table 数组里有 “rohm,dh2228fv”,就可以调用 spi_driver的probe函数了.</p>
<p>至此dts文件已经修改完毕, 只需要编译之后让系统加载这个新的dtb就可以了</p>
<pre><code class="bash">dtc -I dts -O dtb am335x-boneblack.dts &gt; am335x-boneblack.dtb
</code></pre>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/04/27/bbb-build-tree-uart/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/04/27/bbb-build-tree-uart/" itemprop="url">
                  BBB狗板在ubuntu14.04LTS添加Uart1、2、4、5
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-04-27T16:16:53+08:00">
                2017-04-27
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-04-27
			16:16:53
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/BeagleBoneBlack/" itemprop="url" rel="index">
                    <span itemprop="name">BeagleBoneBlack</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/27/bbb-build-tree-uart/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/04/27/bbb-build-tree-uart/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="至于为什么没有Uart3"><a href="#至于为什么没有Uart3" class="headerlink" title="至于为什么没有Uart3"></a>至于为什么没有Uart3</h3><p>   图上可知BBB的uart3只有一个发送，并没有接收，所以本文将不使能该串口，我感觉uart1、2、4、5这四个串口都够用了。<br><img src="http://beagleboard.org/static/images/cape-headers-serial.png" alt="这里写图片描述"></p>
<h3 id="如何使能串口2、4、5"><a href="#如何使能串口2、4、5" class="headerlink" title="如何使能串口2、4、5"></a>如何使能串口2、4、5</h3><p>   博主从 <a href="http://www.armhf.com" target="_blank" rel="external">http://www.armhf.com</a> 下载的ubuntu14.04是默认打开Uart0和1的，因此我们只需要修改2、4、5的串口配置。</p>
<pre><code>http://www.armhf.com/beaglebone-black-serial-uart-device-tree-overlays-for-ubuntu-and-debian-wheezy-tty01-tty02-tty04-tty05-dtbo-files/
</code></pre><p>   外国的朋友在早起已经有了解决方案，可惜这方法失效了，因为在内核版本到3.14之后就不再支持 bone_capemgr 了。</p>
<p>   后来博主在评论区看到armhf的回答，按着他的步骤我驱动起来了。<br>    方法如下：<br>    1、先安装设备树反编译。<br>    2、进入dtbs目录备份原来的，避免错误修改造成开机失败。<br>    3、反编译dtb变成dts<br>    4、用nano或者vim打开dts文件</p>
<pre><code class="bash">apt-get update
apt-get install device-tree-compiler
<span class="built_in">cd</span> /boot/dtbs/
cp am335x-boneblack.dtb am335x-boneblack.dtb_orig  
dtc -I dtb -O dts -o am335x-boneblack.dts   /boot/dtbs/am335x-boneblack.dtb
nano am335x-boneblack.dts
</code></pre>
<p>   打开dts文件后找到：（在该位置删除掉）</p>
<pre><code class="bash">   pinmux_uart2_pins {
    pinctrl-single,pins = &lt;0x150 0x21 0x154 0x1&gt;;
};

pinmux_uart4_pins {
    pinctrl-single,pins = &lt;0x70 0x26 0x74 0x6&gt;;
};

pinmux_uart5_pins {
    pinctrl-single,pins = &lt;0xc4 0x24 0xc0 0x4&gt;;
};
</code></pre>
<p>将其修改成：<strong>（在pinmux@44e10800 section“内”的尾部添加，以免在原位置的时候，后面I2C、SPI会覆盖修改设置，所以追加到后面）</strong><br>    <em>pinctrl-single,pins这个是配置哪个引脚哪个功能的，可以参考数据手册。</em></p>
<pre><code class="bash">pinmux_uart2_pins {
         pinctrl-single,pins = &lt;0x150 0x21 0x154 0x1&gt;;
         linux,phandle = &lt;0x81&gt;;
         phandle = &lt;0x81&gt;;

 };

 pinmux_uart4_pins {
         pinctrl-single,pins = &lt;0x70 0x26 0x74 0x6&gt;;
         linux,phandle = &lt;0x82&gt;;
         phandle = &lt;0x82&gt;;

 };

 pinmux_uart5_pins {
         pinctrl-single,pins = &lt;0xc4 0x24 0xc0 0x4&gt;;
         linux,phandle = &lt;0x83&gt;;
         phandle = &lt;0x83&gt;;

 };
</code></pre>
<p>   然后找串口2、4、5的入口点：（注意：这里uart3对应串口2!）按照下面的修改就可以了。pinctrl-0 = <0x81>;与上面设置的linux,phandle = <0x81>;  phandle = <0x81>;要对应起来。</0x81></0x81></0x81></p>
<pre><code>serial@48024000 {
    compatible = &quot;ti,omap3-uart&quot;;
    ti,hwmods = &quot;uart3&quot;;
    clock-frequency = &lt;0x2dc6c00&gt;;
    reg = &lt;0x48024000 0x2000&gt;;
    interrupts = &lt;0x4a&gt;;
    status = &quot;okay&quot;;
    pinctrl-names = &quot;default&quot;;
    pinctrl-0 = &lt;0x81&gt;;
};

serial@481a6000 {
    compatible = &quot;ti,omap3-uart&quot;;
    ti,hwmods = &quot;uart4&quot;;
    clock-frequency = &lt;0x2dc6c00&gt;;
    reg = &lt;0x481a6000 0x2000&gt;;
    interrupts = &lt;0x2c&gt;;
    status = &quot;disabled&quot;;
};

serial@481a8000 {
    compatible = &quot;ti,omap3-uart&quot;;
    ti,hwmods = &quot;uart5&quot;;
    clock-frequency = &lt;0x2dc6c00&gt;;
    reg = &lt;0x481a8000 0x2000&gt;;
    interrupts = &lt;0x2d&gt;;
    status = &quot;okay&quot;;
    pinctrl-names = &quot;default&quot;;
    pinctrl-0 = &lt;0x82&gt;;

};

serial@481aa000 {
    compatible = &quot;ti,omap3-uart&quot;;
    ti,hwmods = &quot;uart6&quot;;
    clock-frequency = &lt;0x2dc6c00&gt;;
    reg = &lt;0x481aa000 0x2000&gt;;
    interrupts = &lt;0x2e&gt;;
    status = &quot;okay&quot;;
    pinctrl-names = &quot;default&quot;;
    pinctrl-0 = &lt;0x83&gt;;

};
</code></pre><h3 id="最后一步"><a href="#最后一步" class="headerlink" title="最后一步"></a>最后一步</h3><p>在/boot/dtbs/目录内执行，生成新的am335x-boneblack.dtb。</p>
<pre><code class="bash">dtc -I dts -O dtb -o am335x-boneblack.dtb am335x-boneblack.dts
</code></pre>
<h3 id="我的am335x-boneblack-dts参考"><a href="#我的am335x-boneblack-dts参考" class="headerlink" title="我的am335x-boneblack.dts参考"></a>我的am335x-boneblack.dts参考</h3><pre><code class="bash">/dts-v1/;

/ {
    <span class="comment">#address-cells = &lt;0x1&gt;;</span>
    <span class="comment">#size-cells = &lt;0x1&gt;;</span>
    compatible = <span class="string">"ti,am335x-bone"</span>, <span class="string">"ti,am33xx"</span>;
    interrupt-parent = &lt;0x1&gt;;
    model = <span class="string">"TI AM335x BeagleBone"</span>;

    chosen {
    };

    aliases {
        i2c0 = <span class="string">"/ocp/i2c@44e0b000"</span>;
        i2c1 = <span class="string">"/ocp/i2c@4802a000"</span>;
        i2c2 = <span class="string">"/ocp/i2c@4819c000"</span>;
        serial0 = <span class="string">"/ocp/serial@44e09000"</span>;
        serial1 = <span class="string">"/ocp/serial@48022000"</span>;
        serial2 = <span class="string">"/ocp/serial@48024000"</span>;
        serial3 = <span class="string">"/ocp/serial@481a6000"</span>;
        serial4 = <span class="string">"/ocp/serial@481a8000"</span>;
        serial5 = <span class="string">"/ocp/serial@481aa000"</span>;
        d_can0 = <span class="string">"/ocp/d_can@481cc000"</span>;
        d_can1 = <span class="string">"/ocp/d_can@481d0000"</span>;
        usb0 = <span class="string">"/ocp/usb@47400000/usb@47401000"</span>;
        usb1 = <span class="string">"/ocp/usb@47400000/usb@47401800"</span>;
        phy0 = <span class="string">"/ocp/usb@47400000/usb-phy@47401300"</span>;
        phy1 = <span class="string">"/ocp/usb@47400000/usb-phy@47401b00"</span>;
        ethernet0 = <span class="string">"/ocp/ethernet@4a100000/slave@4a100200"</span>;
        ethernet1 = <span class="string">"/ocp/ethernet@4a100000/slave@4a100300"</span>;
    };

    memory {
        device_type = <span class="string">"memory"</span>;
        reg = &lt;0x80000000 0x10000000&gt;;
    };

    cpus {
        <span class="comment">#address-cells = &lt;0x1&gt;;</span>
        <span class="comment">#size-cells = &lt;0x0&gt;;</span>

        cpu@0 {
            compatible = <span class="string">"arm,cortex-a8"</span>;
            device_type = <span class="string">"cpu"</span>;
            reg = &lt;0x0&gt;;
            operating-points = &lt;0xf4240 0x1437c8 0xc3500 0x13d620 0x927c0 0x10f7c0 0x493e0 0xec928&gt;;
            voltage-tolerance = &lt;0x2&gt;;
            clock-latency = &lt;0x493e0&gt;;
            cpu0-supply = &lt;0x2&gt;;
        };
    };

    pmu {
        compatible = <span class="string">"arm,cortex-a8-pmu"</span>;
        interrupts = &lt;0x3&gt;;
    };

    soc {
        compatible = <span class="string">"ti,omap-infra"</span>;

        mpu {
            compatible = <span class="string">"ti,omap3-mpu"</span>;
            ti,hwmods = <span class="string">"mpu"</span>;
        };
    };

    pinmux@44e10800 {
        compatible = <span class="string">"pinctrl-single"</span>;
        reg = &lt;0x44e10800 0x238&gt;;
        <span class="comment">#address-cells = &lt;0x1&gt;;</span>
        <span class="comment">#size-cells = &lt;0x0&gt;;</span>
        pinctrl-single,register-width = &lt;0x20&gt;;
        pinctrl-single,<span class="keyword">function</span>-mask = &lt;0x7f&gt;;
        pinctrl-names = <span class="string">"default"</span>;
        pinctrl-0 = &lt;0x3&gt;;

        user_leds_s0 {
            pinctrl-single,pins = &lt;0x54 0x7 0x58 0x17 0x5c 0x7 0x60 0x17&gt;;
            linux,phandle = &lt;0x40&gt;;
            phandle = &lt;0x40&gt;;
        };

        pinmux_i2c0_pins {
            pinctrl-single,pins = &lt;0x188 0x30 0x18c 0x30&gt;;
            linux,phandle = &lt;0x2a&gt;;
            phandle = &lt;0x2a&gt;;
        };

        pinmux_i2c2_pins {
            pinctrl-single,pins = &lt;0x178 0x73 0x17c 0x73&gt;;
            linux,phandle = &lt;0x2b&gt;;
            phandle = &lt;0x2b&gt;;
        };

        pinmux_uart0_pins {
            pinctrl-single,pins = &lt;0x170 0x30 0x174 0x0&gt;;
            linux,phandle = &lt;0x28&gt;;
            phandle = &lt;0x28&gt;;
        };


        pinmux_clkout2_pin {
            pinctrl-single,pins = &lt;0x1b4 0x3&gt;;
            linux,phandle = &lt;0x3&gt;;
            phandle = &lt;0x3&gt;;
        };

        cpsw_default {
            pinctrl-single,pins = &lt;0x110 0x30 0x114 0x0 0x118 0x30 0x11c 0x0 0x120 0x0 0x124 0x0 0x128 0x0 0x12c 0x30 0x130 0x30 0x134 0x30 0x138 0x30 0x13c 0x30 0x140 0x30&gt;;
            linux,phandle = &lt;0x39&gt;;
            phandle = &lt;0x39&gt;;
        };

        cpsw_sleep {
            pinctrl-single,pins = &lt;0x110 0x27 0x114 0x27 0x118 0x27 0x11c 0x27 0x120 0x27 0x124 0x27 0x128 0x27 0x12c 0x27 0x130 0x27 0x134 0x27 0x138 0x27 0x13c 0x27 0x140 0x27&gt;;
            linux,phandle = &lt;0x3a&gt;;
            phandle = &lt;0x3a&gt;;
        };

        davinci_mdio_default {
            pinctrl-single,pins = &lt;0x148 0x70 0x14c 0x10&gt;;
            linux,phandle = &lt;0x3b&gt;;
            phandle = &lt;0x3b&gt;;
        };

        davinci_mdio_sleep {
            pinctrl-single,pins = &lt;0x148 0x27 0x14c 0x27&gt;;
            linux,phandle = &lt;0x3c&gt;;
            phandle = &lt;0x3c&gt;;
        };

        pinmux_mmc1_pins {
            pinctrl-single,pins = &lt;0x160 0x2f&gt;;
            linux,phandle = &lt;0x2d&gt;;
            phandle = &lt;0x2d&gt;;
        };

        pinmux_emmc_pins {
            pinctrl-single,pins = &lt;0x80 0x32 0x84 0x32 0x0 0x31 0x4 0x31 0x8 0x31 0xc 0x31 0x10 0x31 0x14 0x31 0x18 0x31 0x1c 0x31&gt;;
            linux,phandle = &lt;0x30&gt;;
            phandle = &lt;0x30&gt;;
        };

        pinmux_spi0_pins {
            pinctrl-single,pins = &lt;0x150 0x30 0x154 0x30 0x158 0x10 0x15c 0x10&gt;;
            linux,phandle = &lt;0x31&gt;;
            phandle = &lt;0x31&gt;;
        };

        pinmux_ehrpwm1_pin_p9_14 {
            pinctrl-single,pins = &lt;0x48 0x6&gt;;
            linux,phandle = &lt;0x37&gt;;
            phandle = &lt;0x37&gt;;
        };

        pinmux_ehrpwm1_pin_p9_16 {
            pinctrl-single,pins = &lt;0x4c 0x6&gt;;
            linux,phandle = &lt;0x38&gt;;
            phandle = &lt;0x38&gt;;
        };

        pinmux_ecap0_pin_p9_42 {
            pinctrl-single,pins = &lt;0x164 0x0&gt;;
            linux,phandle = &lt;0x36&gt;;
            phandle = &lt;0x36&gt;;
        };

        nxp_hdmi_bonelt_pins {
            pinctrl-single,pins = &lt;0x1b0 0x3 0xa0 0x8 0xa4 0x8 0xa8 0x8 0xac 0x8 0xb0 0x8 0xb4 0x8 0xb8 0x8 0xbc 0x8 0xc0 0x8 0xc4 0x8 0xc8 0x8 0xcc 0x8 0xd0 0x8 0xd4 0x8 0xd8 0x8 0xdc 0x8 0xe0 0x0 0xe4 0x0 0xe8 0x0 0xec 0x0&gt;;
            linux,phandle = &lt;0x43&gt;;
            phandle = &lt;0x43&gt;;
        };

        nxp_hdmi_bonelt_off_pins {
            pinctrl-single,pins = &lt;0x1b0 0x3&gt;;
            linux,phandle = &lt;0x44&gt;;
            phandle = &lt;0x44&gt;;
        };
        pinmux_uart1_pins {
            pinctrl-single,pins = &lt;0x180 0x30 0x184 0x0&gt;;
            linux,phandle = &lt;0x29&gt;;
            phandle = &lt;0x29&gt;;
        };

        pinmux_uart2_pins {
            pinctrl-single,pins = &lt;0x150 0x21 0x154 0x1&gt;;
            linux,phandle = &lt;0x81&gt;;
            phandle = &lt;0x81&gt;;

        };

        pinmux_uart4_pins {
            pinctrl-single,pins = &lt;0x70 0x26 0x74 0x6&gt;;
            linux,phandle = &lt;0x82&gt;;
            phandle = &lt;0x82&gt;;

        };

        pinmux_uart5_pins {
            pinctrl-single,pins = &lt;0xc4 0x24 0xc0 0x4&gt;;
            linux,phandle = &lt;0x83&gt;;
            phandle = &lt;0x83&gt;;

        };

    };

    ocp {
        compatible = <span class="string">"simple-bus"</span>;
        <span class="comment">#address-cells = &lt;0x1&gt;;</span>
        <span class="comment">#size-cells = &lt;0x1&gt;;</span>
        ranges;
        ti,hwmods = <span class="string">"l3_main"</span>;

        prcm@44e00000 {
            compatible = <span class="string">"ti,am3-prcm"</span>;
            reg = &lt;0x44e00000 0x4000&gt;;

            clocks {
                <span class="comment">#address-cells = &lt;0x1&gt;;</span>
                <span class="comment">#size-cells = &lt;0x0&gt;;</span>

                clk_32768_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x8000&gt;;
                    linux,phandle = &lt;0x15&gt;;
                    phandle = &lt;0x15&gt;;
                };

                clk_rc32k_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x7d00&gt;;
                    linux,phandle = &lt;0x14&gt;;
                    phandle = &lt;0x14&gt;;
                };

                virt_19200000_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x124f800&gt;;
                    linux,phandle = &lt;0x21&gt;;
                    phandle = &lt;0x21&gt;;
                };

                virt_24000000_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x16e3600&gt;;
                    linux,phandle = &lt;0x22&gt;;
                    phandle = &lt;0x22&gt;;
                };

                virt_25000000_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x17d7840&gt;;
                    linux,phandle = &lt;0x23&gt;;
                    phandle = &lt;0x23&gt;;
                };

                virt_26000000_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0x18cba80&gt;;
                    linux,phandle = &lt;0x24&gt;;
                    phandle = &lt;0x24&gt;;
                };

                tclkin_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-clock"</span>;
                    clock-frequency = &lt;0xb71b00&gt;;
                    linux,phandle = &lt;0x13&gt;;
                    phandle = &lt;0x13&gt;;
                };

                dpll_core_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-core-clock"</span>;
                    clocks = &lt;0x4 0x4&gt;;
                    reg = &lt;0x490 0x45c 0x468&gt;;
                    linux,phandle = &lt;0x5&gt;;
                    phandle = &lt;0x5&gt;;
                };

                dpll_core_x2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-x2-clock"</span>;
                    clocks = &lt;0x5&gt;;
                    linux,phandle = &lt;0x6&gt;;
                    phandle = &lt;0x6&gt;;
                };

                dpll_core_m4_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x6&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x480&gt;;
                    ti,index-starts-at-one;
                    linux,phandle = &lt;0xf&gt;;
                    phandle = &lt;0xf&gt;;
                };

                dpll_core_m5_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x6&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x484&gt;;
                    ti,index-starts-at-one;
                    linux,phandle = &lt;0x17&gt;;
                    phandle = &lt;0x17&gt;;
                };

                dpll_core_m6_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x6&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x4d8&gt;;
                    ti,index-starts-at-one;
                };

                dpll_mpu_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-clock"</span>;
                    clocks = &lt;0x4 0x4&gt;;
                    reg = &lt;0x488 0x420 0x42c&gt;;
                    linux,phandle = &lt;0x7&gt;;
                    phandle = &lt;0x7&gt;;
                };

                dpll_mpu_m2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x7&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x4a8&gt;;
                    ti,index-starts-at-one;
                };

                dpll_ddr_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-no-gate-clock"</span>;
                    clocks = &lt;0x4 0x4&gt;;
                    reg = &lt;0x494 0x434 0x440&gt;;
                    linux,phandle = &lt;0x8&gt;;
                    phandle = &lt;0x8&gt;;
                };

                dpll_ddr_m2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x8&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x4a0&gt;;
                    ti,index-starts-at-one;
                    linux,phandle = &lt;0x9&gt;;
                    phandle = &lt;0x9&gt;;
                };

                dpll_ddr_m2_div2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x9&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2&gt;;
                };

                dpll_disp_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-no-gate-clock"</span>;
                    clocks = &lt;0x4 0x4&gt;;
                    reg = &lt;0x498 0x448 0x454&gt;;
                    linux,phandle = &lt;0xa&gt;;
                    phandle = &lt;0xa&gt;;
                };

                dpll_disp_m2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0xa&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x4a4&gt;;
                    ti,index-starts-at-one;
                    ti,<span class="built_in">set</span>-rate-parent;
                    linux,phandle = &lt;0x11&gt;;
                    phandle = &lt;0x11&gt;;
                };

                dpll_per_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,am3-dpll-no-gate-j-type-clock"</span>;
                    clocks = &lt;0x4 0x4&gt;;
                    reg = &lt;0x48c 0x470 0x49c&gt;;
                    linux,phandle = &lt;0xb&gt;;
                    phandle = &lt;0xb&gt;;
                };

                dpll_per_m2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0xb&gt;;
                    ti,max-div = &lt;0x1f&gt;;
                    reg = &lt;0x4ac&gt;;
                    ti,index-starts-at-one;
                    linux,phandle = &lt;0xc&gt;;
                    phandle = &lt;0xc&gt;;
                };

                dpll_per_m2_div4_wkupdm_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x4&gt;;
                };

                dpll_per_m2_div4_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x4&gt;;
                };

                cefuse_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0xa20&gt;;
                };

                clk_24mhz {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x8&gt;;
                    linux,phandle = &lt;0xd&gt;;
                    phandle = &lt;0xd&gt;;
                };

                clkdiv32k_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xd&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2dc&gt;;
                    linux,phandle = &lt;0xe&gt;;
                    phandle = &lt;0xe&gt;;
                };

                clkdiv32k_ick {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0xe&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0x14c&gt;;
                    linux,phandle = &lt;0x12&gt;;
                    phandle = &lt;0x12&gt;;
                };

                l3_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                    linux,phandle = &lt;0x10&gt;;
                    phandle = &lt;0x10&gt;;
                };

                pruss_ocp_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x10 0x11&gt;;
                    reg = &lt;0x530&gt;;
                };

                mmu_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0x914&gt;;
                };

                timer1_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x4 0x12 0x13 0x14 0x15&gt;;
                    reg = &lt;0x528&gt;;
                };

                timer2_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x508&gt;;
                };

                timer3_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x50c&gt;;
                };

                timer4_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x510&gt;;
                };

                timer5_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x518&gt;;
                };

                timer6_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x51c&gt;;
                };

                timer7_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x13 0x4 0x12&gt;;
                    reg = &lt;0x504&gt;;
                };

                usbotg_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0xb&gt;;
                    ti,bit-shift = &lt;0x8&gt;;
                    reg = &lt;0x47c&gt;;
                };

                dpll_core_m4_div2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2&gt;;
                    linux,phandle = &lt;0x16&gt;;
                    phandle = &lt;0x16&gt;;
                };

                ieee5000_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x16&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0xe4&gt;;
                };

                wdt1_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x14 0x12&gt;;
                    reg = &lt;0x538&gt;;
                };

                l4_rtc_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2&gt;;
                };

                l4hs_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                l3s_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x16&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                l4fw_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x16&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                l4ls_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x16&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                sysclk_div_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                cpsw_125mhz_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x17&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2&gt;;
                };

                cpsw_cpts_rft_clk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x17 0xf&gt;;
                    reg = &lt;0x520&gt;;
                };

                gpio0_dbclk_mux_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x14 0x15 0x12&gt;;
                    reg = &lt;0x53c&gt;;
                    linux,phandle = &lt;0x18&gt;;
                    phandle = &lt;0x18&gt;;
                };

                gpio0_dbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x18&gt;;
                    ti,bit-shift = &lt;0x12&gt;;
                    reg = &lt;0x408&gt;;
                };

                gpio1_dbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x12&gt;;
                    ti,bit-shift = &lt;0x12&gt;;
                    reg = &lt;0xac&gt;;
                };

                gpio2_dbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x12&gt;;
                    ti,bit-shift = &lt;0x12&gt;;
                    reg = &lt;0xb0&gt;;
                };

                gpio3_dbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x12&gt;;
                    ti,bit-shift = &lt;0x12&gt;;
                    reg = &lt;0xb4&gt;;
                };

                lcd_gclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x11 0x17 0xc&gt;;
                    reg = &lt;0x534&gt;;
                    ti,<span class="built_in">set</span>-rate-parent;
                    linux,phandle = &lt;0x1a&gt;;
                    phandle = &lt;0x1a&gt;;
                };

                mmc_clk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x2&gt;;
                };

                gfx_fclk_clksel_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0xf 0xc&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0x52c&gt;;
                    linux,phandle = &lt;0x19&gt;;
                    phandle = &lt;0x19&gt;;
                };

                gfx_fck_div_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x19&gt;;
                    reg = &lt;0x52c&gt;;
                    ti,max-div = &lt;0x2&gt;;
                };

                sysclkout_pre_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x15 0x10 0x9 0xc 0x1a&gt;;
                    reg = &lt;0x700&gt;;
                    linux,phandle = &lt;0x1b&gt;;
                    phandle = &lt;0x1b&gt;;
                };

                clkout2_div_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x1b&gt;;
                    ti,bit-shift = &lt;0x3&gt;;
                    ti,max-div = &lt;0x8&gt;;
                    reg = &lt;0x700&gt;;
                    linux,phandle = &lt;0x20&gt;;
                    phandle = &lt;0x20&gt;;
                };

                dbg_sysclk_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    ti,bit-shift = &lt;0x13&gt;;
                    reg = &lt;0x414&gt;;
                    linux,phandle = &lt;0x1c&gt;;
                    phandle = &lt;0x1c&gt;;
                };

                dbg_clka_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0xf&gt;;
                    ti,bit-shift = &lt;0x1e&gt;;
                    reg = &lt;0x414&gt;;
                    linux,phandle = &lt;0x1d&gt;;
                    phandle = &lt;0x1d&gt;;
                };

                stm_pmd_clock_mux_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x1c 0x1d&gt;;
                    ti,bit-shift = &lt;0x16&gt;;
                    reg = &lt;0x414&gt;;
                    linux,phandle = &lt;0x1e&gt;;
                    phandle = &lt;0x1e&gt;;
                };

                trace_pmd_clk_mux_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x1c 0x1d&gt;;
                    ti,bit-shift = &lt;0x14&gt;;
                    reg = &lt;0x414&gt;;
                    linux,phandle = &lt;0x1f&gt;;
                    phandle = &lt;0x1f&gt;;
                };

                stm_clk_div_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x1e&gt;;
                    ti,bit-shift = &lt;0x1b&gt;;
                    ti,max-div = &lt;0x40&gt;;
                    reg = &lt;0x414&gt;;
                    ti,index-power-of-two;
                };

                trace_clk_div_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,divider-clock"</span>;
                    clocks = &lt;0x1f&gt;;
                    ti,bit-shift = &lt;0x18&gt;;
                    ti,max-div = &lt;0x40&gt;;
                    reg = &lt;0x414&gt;;
                    ti,index-power-of-two;
                };

                clkout2_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,gate-clock"</span>;
                    clocks = &lt;0x20&gt;;
                    ti,bit-shift = &lt;0x7&gt;;
                    reg = &lt;0x700&gt;;
                };
            };

            clockdomains {

                clk_24mhz_clkdm {
                    compatible = <span class="string">"ti,clockdomain"</span>;
                    clocks = &lt;0x12&gt;;
                };
            };
        };

        scrm@44e10000 {
            compatible = <span class="string">"ti,am3-scrm"</span>;
            reg = &lt;0x44e10000 0x2000&gt;;

            clocks {
                <span class="comment">#address-cells = &lt;0x1&gt;;</span>
                <span class="comment">#size-cells = &lt;0x0&gt;;</span>

                sys_clkin_ck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,mux-clock"</span>;
                    clocks = &lt;0x21 0x22 0x23 0x24&gt;;
                    ti,bit-shift = &lt;0x16&gt;;
                    reg = &lt;0x40&gt;;
                    linux,phandle = &lt;0x4&gt;;
                    phandle = &lt;0x4&gt;;
                };

                adc_tsc_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                dcan0_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                dcan1_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                mcasp0_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                mcasp1_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                smartreflex0_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                smartreflex1_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                sha0_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                aes0_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                rng_fck {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"fixed-factor-clock"</span>;
                    clocks = &lt;0x4&gt;;
                    clock-mult = &lt;0x1&gt;;
                    clock-div = &lt;0x1&gt;;
                };

                ehrpwm0_gate_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-no-wait-gate-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    ti,bit-shift = &lt;0x0&gt;;
                    reg = &lt;0x664&gt;;
                    linux,phandle = &lt;0x25&gt;;
                    phandle = &lt;0x25&gt;;
                };

                ehrpwm0_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-clock"</span>;
                    clocks = &lt;0x25&gt;;
                };

                ehrpwm1_gate_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-no-wait-gate-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    ti,bit-shift = &lt;0x1&gt;;
                    reg = &lt;0x664&gt;;
                    linux,phandle = &lt;0x26&gt;;
                    phandle = &lt;0x26&gt;;
                };

                ehrpwm1_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-clock"</span>;
                    clocks = &lt;0x26&gt;;
                };

                ehrpwm2_gate_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-no-wait-gate-clock"</span>;
                    clocks = &lt;0xc&gt;;
                    ti,bit-shift = &lt;0x2&gt;;
                    reg = &lt;0x664&gt;;
                    linux,phandle = &lt;0x27&gt;;
                    phandle = &lt;0x27&gt;;
                };

                ehrpwm2_tbclk {
                    <span class="comment">#clock-cells = &lt;0x0&gt;;</span>
                    compatible = <span class="string">"ti,composite-clock"</span>;
                    clocks = &lt;0x27&gt;;
                };
            };

            clockdomains {
            };
        };

        interrupt-controller@48200000 {
            compatible = <span class="string">"ti,omap2-intc"</span>;
            interrupt-controller;
            <span class="comment">#interrupt-cells = &lt;0x1&gt;;</span>
            ti,intc-size = &lt;0x80&gt;;
            reg = &lt;0x48200000 0x1000&gt;;
            linux,phandle = &lt;0x1&gt;;
            phandle = &lt;0x1&gt;;
        };

        edma@49000000 {
            compatible = <span class="string">"ti,edma3"</span>;
            ti,hwmods = <span class="string">"tpcc"</span>, <span class="string">"tptc0"</span>, <span class="string">"tptc1"</span>, <span class="string">"tptc2"</span>;
            reg = &lt;0x49000000 0x10000 0x44e10f90 0x10&gt;;
            interrupts = &lt;0xc 0xd 0xe&gt;;
            <span class="comment">#dma-cells = &lt;0x1&gt;;</span>
            dma-channels = &lt;0x40&gt;;
            ti,edma-regions = &lt;0x4&gt;;
            ti,edma-slots = &lt;0x100&gt;;
            linux,phandle = &lt;0x2c&gt;;
            phandle = &lt;0x2c&gt;;
        };

        gpio@44e07000 {
            compatible = <span class="string">"ti,omap4-gpio"</span>;
            ti,hwmods = <span class="string">"gpio1"</span>;
            gpio-controller;
            <span class="comment">#gpio-cells = &lt;0x2&gt;;</span>
            interrupt-controller;
            <span class="comment">#interrupt-cells = &lt;0x2&gt;;</span>
            reg = &lt;0x44e07000 0x1000&gt;;
            interrupts = &lt;0x60&gt;;
            linux,phandle = &lt;0x2e&gt;;
            phandle = &lt;0x2e&gt;;
        };

        gpio@4804c000 {
            compatible = <span class="string">"ti,omap4-gpio"</span>;
            ti,hwmods = <span class="string">"gpio2"</span>;
            gpio-controller;
            <span class="comment">#gpio-cells = &lt;0x2&gt;;</span>
            interrupt-controller;
            <span class="comment">#interrupt-cells = &lt;0x2&gt;;</span>
            reg = &lt;0x4804c000 0x1000&gt;;
            interrupts = &lt;0x62&gt;;
            linux,phandle = &lt;0x41&gt;;
            phandle = &lt;0x41&gt;;
        };

        gpio@481ac000 {
            compatible = <span class="string">"ti,omap4-gpio"</span>;
            ti,hwmods = <span class="string">"gpio3"</span>;
            gpio-controller;
            <span class="comment">#gpio-cells = &lt;0x2&gt;;</span>
            interrupt-controller;
            <span class="comment">#interrupt-cells = &lt;0x2&gt;;</span>
            reg = &lt;0x481ac000 0x1000&gt;;
            interrupts = &lt;0x20&gt;;
        };

        gpio@481ae000 {
            compatible = <span class="string">"ti,omap4-gpio"</span>;
            ti,hwmods = <span class="string">"gpio4"</span>;
            gpio-controller;
            <span class="comment">#gpio-cells = &lt;0x2&gt;;</span>
            interrupt-controller;
            <span class="comment">#interrupt-cells = &lt;0x2&gt;;</span>
            reg = &lt;0x481ae000 0x1000&gt;;
            interrupts = &lt;0x3e&gt;;
        };

        serial@44e09000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart1"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x44e09000 0x2000&gt;;
            interrupts = &lt;0x48&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x28&gt;;
        };

        serial@48022000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart2"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x48022000 0x2000&gt;;
            interrupts = &lt;0x49&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x29&gt;;
        };

        serial@48024000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart3"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x48024000 0x2000&gt;;
            interrupts = &lt;0x4a&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x81&gt;;
        };

        serial@481a6000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart4"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x481a6000 0x2000&gt;;
            interrupts = &lt;0x2c&gt;;
            status = <span class="string">"disabled"</span>;
        };

        serial@481a8000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart5"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x481a8000 0x2000&gt;;
            interrupts = &lt;0x2d&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x82&gt;;

        };

        serial@481aa000 {
            compatible = <span class="string">"ti,omap3-uart"</span>;
            ti,hwmods = <span class="string">"uart6"</span>;
            clock-frequency = &lt;0x2dc6c00&gt;;
            reg = &lt;0x481aa000 0x2000&gt;;
            interrupts = &lt;0x2e&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x83&gt;;

        };

        i2c@44e0b000 {
            compatible = <span class="string">"ti,omap4-i2c"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x0&gt;;</span>
            ti,hwmods = <span class="string">"i2c1"</span>;
            reg = &lt;0x44e0b000 0x1000&gt;;
            interrupts = &lt;0x46&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x2a&gt;;
            clock-frequency = &lt;0x61a80&gt;;
            linux,phandle = &lt;0x42&gt;;
            phandle = &lt;0x42&gt;;

            tps@24 {
                reg = &lt;0x24&gt;;
                compatible = <span class="string">"ti,tps65217"</span>;

                regulators {
                    <span class="comment">#address-cells = &lt;0x1&gt;;</span>
                    <span class="comment">#size-cells = &lt;0x0&gt;;</span>

                    regulator@0 {
                        reg = &lt;0x0&gt;;
                        regulator-compatible = <span class="string">"dcdc1"</span>;
                        regulator-always-on;
                    };

                    regulator@1 {
                        reg = &lt;0x1&gt;;
                        regulator-compatible = <span class="string">"dcdc2"</span>;
                        regulator-name = <span class="string">"vdd_mpu"</span>;
                        regulator-min-microvolt = &lt;0xe1d48&gt;;
                        regulator-max-microvolt = &lt;0x1437c8&gt;;
                        regulator-boot-on;
                        regulator-always-on;
                        linux,phandle = &lt;0x2&gt;;
                        phandle = &lt;0x2&gt;;
                    };

                    regulator@2 {
                        reg = &lt;0x2&gt;;
                        regulator-compatible = <span class="string">"dcdc3"</span>;
                        regulator-name = <span class="string">"vdd_core"</span>;
                        regulator-min-microvolt = &lt;0xe1d48&gt;;
                        regulator-max-microvolt = &lt;0x118c30&gt;;
                        regulator-boot-on;
                        regulator-always-on;
                    };

                    regulator@3 {
                        reg = &lt;0x3&gt;;
                        regulator-compatible = <span class="string">"ldo1"</span>;
                        regulator-always-on;
                    };

                    regulator@4 {
                        reg = &lt;0x4&gt;;
                        regulator-compatible = <span class="string">"ldo2"</span>;
                        regulator-always-on;
                    };

                    regulator@5 {
                        reg = &lt;0x5&gt;;
                        regulator-compatible = <span class="string">"ldo3"</span>;
                        regulator-always-on;
                        regulator-min-microvolt = &lt;0x1b7740&gt;;
                        regulator-max-microvolt = &lt;0x1b7740&gt;;
                    };

                    regulator@6 {
                        reg = &lt;0x6&gt;;
                        regulator-compatible = <span class="string">"ldo4"</span>;
                        regulator-always-on;
                    };
                };
            };

            baseboard_eeprom@50 {
                compatible = <span class="string">"at,24c256"</span>;
                reg = &lt;0x50&gt;;
            };
        };

        i2c@4802a000 {
            compatible = <span class="string">"ti,omap4-i2c"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x0&gt;;</span>
            ti,hwmods = <span class="string">"i2c2"</span>;
            reg = &lt;0x4802a000 0x1000&gt;;
            interrupts = &lt;0x47&gt;;
            status = <span class="string">"disabled"</span>;
        };

        i2c@4819c000 {
            compatible = <span class="string">"ti,omap4-i2c"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x0&gt;;</span>
            ti,hwmods = <span class="string">"i2c3"</span>;
            reg = &lt;0x4819c000 0x1000&gt;;
            interrupts = &lt;0x1e&gt;;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x2b&gt;;
            clock-frequency = &lt;0x186a0&gt;;

            cape_eeprom0@54 {
                compatible = <span class="string">"at,24c256"</span>;
                reg = &lt;0x54&gt;;
            };

            cape_eeprom1@55 {
                compatible = <span class="string">"at,24c256"</span>;
                reg = &lt;0x55&gt;;
            };

            cape_eeprom2@56 {
                compatible = <span class="string">"at,24c256"</span>;
                reg = &lt;0x56&gt;;
            };

            cape_eeprom3@57 {
                compatible = <span class="string">"at,24c256"</span>;
                reg = &lt;0x57&gt;;
            };
        };

        mmc@48060000 {
            compatible = <span class="string">"ti,omap4-hsmmc"</span>;
            ti,hwmods = <span class="string">"mmc1"</span>;
            ti,dual-volt;
            ti,needs-special-reset;
            ti,needs-special-hs-handling;
            dmas = &lt;0x2c 0x18 0x2c 0x19&gt;;
            dma-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
            interrupts = &lt;0x40&gt;;
            interrupt-parent = &lt;0x1&gt;;
            reg = &lt;0x48060000 0x1000&gt;;
            status = <span class="string">"okay"</span>;
            bus-width = &lt;0x4&gt;;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x2d&gt;;
            <span class="built_in">cd</span>-gpios = &lt;0x2e 0x6 0x0&gt;;
            <span class="built_in">cd</span>-inverted;
            vmmc-supply = &lt;0x2f&gt;;
        };

        mmc@481d8000 {
            compatible = <span class="string">"ti,omap4-hsmmc"</span>;
            ti,hwmods = <span class="string">"mmc2"</span>;
            ti,needs-special-reset;
            dmas = &lt;0x2c 0x2 0x2c 0x3&gt;;
            dma-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
            interrupts = &lt;0x1c&gt;;
            interrupt-parent = &lt;0x1&gt;;
            reg = &lt;0x481d8000 0x1000&gt;;
            status = <span class="string">"okay"</span>;
            vmmc-supply = &lt;0x2f&gt;;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x30&gt;;
            bus-width = &lt;0x8&gt;;
            ti,vcc-aux-disable-is-sleep;
        };

        mmc@47810000 {
            compatible = <span class="string">"ti,omap4-hsmmc"</span>;
            ti,hwmods = <span class="string">"mmc3"</span>;
            ti,needs-special-reset;
            interrupts = &lt;0x1d&gt;;
            interrupt-parent = &lt;0x1&gt;;
            reg = &lt;0x47810000 0x1000&gt;;
            status = <span class="string">"disabled"</span>;
        };

        spinlock@480ca000 {
            compatible = <span class="string">"ti,omap4-hwspinlock"</span>;
            reg = &lt;0x480ca000 0x1000&gt;;
            ti,hwmods = <span class="string">"spinlock"</span>;
        };

        wdt@44e35000 {
            compatible = <span class="string">"ti,omap3-wdt"</span>;
            ti,hwmods = <span class="string">"wd_timer2"</span>;
            reg = &lt;0x44e35000 0x1000&gt;;
            interrupts = &lt;0x5b&gt;;
        };

        d_can@481cc000 {
            compatible = <span class="string">"bosch,d_can"</span>;
            ti,hwmods = <span class="string">"d_can0"</span>;
            reg = &lt;0x481cc000 0x2000 0x44e10644 0x4&gt;;
            interrupts = &lt;0x34&gt;;
            status = <span class="string">"disabled"</span>;
        };

        d_can@481d0000 {
            compatible = <span class="string">"bosch,d_can"</span>;
            ti,hwmods = <span class="string">"d_can1"</span>;
            reg = &lt;0x481d0000 0x2000 0x44e10644 0x4&gt;;
            interrupts = &lt;0x37&gt;;
            status = <span class="string">"disabled"</span>;
        };

        timer@44e31000 {
            compatible = <span class="string">"ti,am335x-timer-1ms"</span>;
            reg = &lt;0x44e31000 0x400&gt;;
            interrupts = &lt;0x43&gt;;
            ti,hwmods = <span class="string">"timer1"</span>;
            ti,timer-alwon;
        };

        timer@48040000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x48040000 0x400&gt;;
            interrupts = &lt;0x44&gt;;
            ti,hwmods = <span class="string">"timer2"</span>;
        };

        timer@48042000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x48042000 0x400&gt;;
            interrupts = &lt;0x45&gt;;
            ti,hwmods = <span class="string">"timer3"</span>;
        };

        timer@48044000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x48044000 0x400&gt;;
            interrupts = &lt;0x5c&gt;;
            ti,hwmods = <span class="string">"timer4"</span>;
            ti,timer-pwm;
        };

        timer@48046000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x48046000 0x400&gt;;
            interrupts = &lt;0x5d&gt;;
            ti,hwmods = <span class="string">"timer5"</span>;
            ti,timer-pwm;
        };

        timer@48048000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x48048000 0x400&gt;;
            interrupts = &lt;0x5e&gt;;
            ti,hwmods = <span class="string">"timer6"</span>;
            ti,timer-pwm;
        };

        timer@4804a000 {
            compatible = <span class="string">"ti,am335x-timer"</span>;
            reg = &lt;0x4804a000 0x400&gt;;
            interrupts = &lt;0x5f&gt;;
            ti,hwmods = <span class="string">"timer7"</span>;
            ti,timer-pwm;
        };

        rtc@44e3e000 {
            compatible = <span class="string">"ti,da830-rtc"</span>;
            reg = &lt;0x44e3e000 0x1000&gt;;
            interrupts = &lt;0x4b 0x4c&gt;;
            ti,hwmods = <span class="string">"rtc"</span>;
        };

        spi@48030000 {
            compatible = <span class="string">"ti,omap4-mcspi"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x0&gt;;</span>
            reg = &lt;0x48030000 0x400&gt;;
            interrupts = &lt;0x41&gt;;
            ti,spi-num-cs = &lt;0x2&gt;;
            ti,hwmods = <span class="string">"spi0"</span>;
            dmas = &lt;0x2c 0x10 0x2c 0x11 0x2c 0x12 0x2c 0x13&gt;;
            dma-names = <span class="string">"tx0"</span>, <span class="string">"rx0"</span>, <span class="string">"tx1"</span>, <span class="string">"rx1"</span>;
            status = <span class="string">"okay"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x31&gt;;

            spi@0 {
                compatible = <span class="string">"spidev"</span>;
                reg = &lt;0x0&gt;;
                spi-max-frequency = &lt;0xf42400&gt;;
                spi-cpha;
            };

            spi@1 {
                compatible = <span class="string">"spidev"</span>;
                reg = &lt;0x1&gt;;
                spi-max-frequency = &lt;0xf42400&gt;;
            };
        };

        spi@481a0000 {
            compatible = <span class="string">"ti,omap4-mcspi"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x0&gt;;</span>
            reg = &lt;0x481a0000 0x400&gt;;
            interrupts = &lt;0x7d&gt;;
            ti,spi-num-cs = &lt;0x2&gt;;
            ti,hwmods = <span class="string">"spi1"</span>;
            dmas = &lt;0x2c 0x2a 0x2c 0x2b 0x2c 0x2c 0x2c 0x2d&gt;;
            dma-names = <span class="string">"tx0"</span>, <span class="string">"rx0"</span>, <span class="string">"tx1"</span>, <span class="string">"rx1"</span>;
            status = <span class="string">"disabled"</span>;
        };

        usb@47400000 {
            compatible = <span class="string">"ti,am33xx-usb"</span>;
            reg = &lt;0x47400000 0x1000&gt;;
            ranges;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            ti,hwmods = <span class="string">"usb_otg_hs"</span>;
            status = <span class="string">"okay"</span>;

            control@44e10620 {
                compatible = <span class="string">"ti,am335x-usb-ctrl-module"</span>;
                reg = &lt;0x44e10620 0x10 0x44e10648 0x4&gt;;
                reg-names = <span class="string">"phy_ctrl"</span>, <span class="string">"wakeup"</span>;
                status = <span class="string">"okay"</span>;
                linux,phandle = &lt;0x32&gt;;
                phandle = &lt;0x32&gt;;
            };

            usb-phy@47401300 {
                compatible = <span class="string">"ti,am335x-usb-phy"</span>;
                reg = &lt;0x47401300 0x100&gt;;
                reg-names = <span class="string">"phy"</span>;
                status = <span class="string">"okay"</span>;
                ti,ctrl_mod = &lt;0x32&gt;;
                linux,phandle = &lt;0x33&gt;;
                phandle = &lt;0x33&gt;;
            };

            usb@47401000 {
                compatible = <span class="string">"ti,musb-am33xx"</span>;
                status = <span class="string">"okay"</span>;
                reg = &lt;0x47401400 0x400 0x47401000 0x200&gt;;
                reg-names = <span class="string">"mc"</span>, <span class="string">"control"</span>;
                interrupts = &lt;0x12&gt;;
                interrupt-names = <span class="string">"mc"</span>;
                dr_mode = <span class="string">"otg"</span>;
                mentor,multipoint = &lt;0x1&gt;;
                mentor,num-eps = &lt;0x10&gt;;
                mentor,ram-bits = &lt;0xc&gt;;
                mentor,power = &lt;0x1f4&gt;;
                phys = &lt;0x33&gt;;
                dmas = &lt;0x34 0x0 0x0 0x34 0x1 0x0 0x34 0x2 0x0 0x34 0x3 0x0 0x34 0x4 0x0 0x34 0x5 0x0 0x34 0x6 0x0 0x34 0x7 0x0 0x34 0x8 0x0 0x34 0x9 0x0 0x34 0xa 0x0 0x34 0xb 0x0 0x34 0xc 0x0 0x34 0xd 0x0 0x34 0xe 0x0 0x34 0x0 0x1 0x34 0x1 0x1 0x34 0x2 0x1 0x34 0x3 0x1 0x34 0x4 0x1 0x34 0x5 0x1 0x34 0x6 0x1 0x34 0x7 0x1 0x34 0x8 0x1 0x34 0x9 0x1 0x34 0xa 0x1 0x34 0xb 0x1 0x34 0xc 0x1 0x34 0xd 0x1 0x34 0xe 0x1&gt;;
                dma-names = <span class="string">"rx1"</span>, <span class="string">"rx2"</span>, <span class="string">"rx3"</span>, <span class="string">"rx4"</span>, <span class="string">"rx5"</span>, <span class="string">"rx6"</span>, <span class="string">"rx7"</span>, <span class="string">"rx8"</span>, <span class="string">"rx9"</span>, <span class="string">"rx10"</span>, <span class="string">"rx11"</span>, <span class="string">"rx12"</span>, <span class="string">"rx13"</span>, <span class="string">"rx14"</span>, <span class="string">"rx15"</span>, <span class="string">"tx1"</span>, <span class="string">"tx2"</span>, <span class="string">"tx3"</span>, <span class="string">"tx4"</span>, <span class="string">"tx5"</span>, <span class="string">"tx6"</span>, <span class="string">"tx7"</span>, <span class="string">"tx8"</span>, <span class="string">"tx9"</span>, <span class="string">"tx10"</span>, <span class="string">"tx11"</span>, <span class="string">"tx12"</span>, <span class="string">"tx13"</span>, <span class="string">"tx14"</span>, <span class="string">"tx15"</span>;
            };

            usb-phy@47401b00 {
                compatible = <span class="string">"ti,am335x-usb-phy"</span>;
                reg = &lt;0x47401b00 0x100&gt;;
                reg-names = <span class="string">"phy"</span>;
                status = <span class="string">"okay"</span>;
                ti,ctrl_mod = &lt;0x32&gt;;
                linux,phandle = &lt;0x35&gt;;
                phandle = &lt;0x35&gt;;
            };

            usb@47401800 {
                compatible = <span class="string">"ti,musb-am33xx"</span>;
                status = <span class="string">"okay"</span>;
                reg = &lt;0x47401c00 0x400 0x47401800 0x200&gt;;
                reg-names = <span class="string">"mc"</span>, <span class="string">"control"</span>;
                interrupts = &lt;0x13&gt;;
                interrupt-names = <span class="string">"mc"</span>;
                dr_mode = <span class="string">"host"</span>;
                mentor,multipoint = &lt;0x1&gt;;
                mentor,num-eps = &lt;0x10&gt;;
                mentor,ram-bits = &lt;0xc&gt;;
                mentor,power = &lt;0x1f4&gt;;
                phys = &lt;0x35&gt;;
                dmas = &lt;0x34 0xf 0x0 0x34 0x10 0x0 0x34 0x11 0x0 0x34 0x12 0x0 0x34 0x13 0x0 0x34 0x14 0x0 0x34 0x15 0x0 0x34 0x16 0x0 0x34 0x17 0x0 0x34 0x18 0x0 0x34 0x19 0x0 0x34 0x1a 0x0 0x34 0x1b 0x0 0x34 0x1c 0x0 0x34 0x1d 0x0 0x34 0xf 0x1 0x34 0x10 0x1 0x34 0x11 0x1 0x34 0x12 0x1 0x34 0x13 0x1 0x34 0x14 0x1 0x34 0x15 0x1 0x34 0x16 0x1 0x34 0x17 0x1 0x34 0x18 0x1 0x34 0x19 0x1 0x34 0x1a 0x1 0x34 0x1b 0x1 0x34 0x1c 0x1 0x34 0x1d 0x1&gt;;
                dma-names = <span class="string">"rx1"</span>, <span class="string">"rx2"</span>, <span class="string">"rx3"</span>, <span class="string">"rx4"</span>, <span class="string">"rx5"</span>, <span class="string">"rx6"</span>, <span class="string">"rx7"</span>, <span class="string">"rx8"</span>, <span class="string">"rx9"</span>, <span class="string">"rx10"</span>, <span class="string">"rx11"</span>, <span class="string">"rx12"</span>, <span class="string">"rx13"</span>, <span class="string">"rx14"</span>, <span class="string">"rx15"</span>, <span class="string">"tx1"</span>, <span class="string">"tx2"</span>, <span class="string">"tx3"</span>, <span class="string">"tx4"</span>, <span class="string">"tx5"</span>, <span class="string">"tx6"</span>, <span class="string">"tx7"</span>, <span class="string">"tx8"</span>, <span class="string">"tx9"</span>, <span class="string">"tx10"</span>, <span class="string">"tx11"</span>, <span class="string">"tx12"</span>, <span class="string">"tx13"</span>, <span class="string">"tx14"</span>, <span class="string">"tx15"</span>;
            };

            dma-controller@47402000 {
                compatible = <span class="string">"ti,am3359-cppi41"</span>;
                reg = &lt;0x47400000 0x1000 0x47402000 0x1000 0x47403000 0x1000 0x47404000 0x4000&gt;;
                reg-names = <span class="string">"glue"</span>, <span class="string">"controller"</span>, <span class="string">"scheduler"</span>, <span class="string">"queuemgr"</span>;
                interrupts = &lt;0x11&gt;;
                interrupt-names = <span class="string">"glue"</span>;
                <span class="comment">#dma-cells = &lt;0x2&gt;;</span>
                <span class="comment">#dma-channels = &lt;0x1e&gt;;</span>
                <span class="comment">#dma-requests = &lt;0x100&gt;;</span>
                status = <span class="string">"okay"</span>;
                linux,phandle = &lt;0x34&gt;;
                phandle = &lt;0x34&gt;;
            };
        };

        epwmss@48300000 {
            compatible = <span class="string">"ti,am33xx-pwmss"</span>;
            reg = &lt;0x48300000 0x10&gt;;
            ti,hwmods = <span class="string">"epwmss0"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            status = <span class="string">"okay"</span>;
            ranges = &lt;0x48300100 0x48300100 0x80 0x48300180 0x48300180 0x80 0x48300200 0x48300200 0x80&gt;;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x36&gt;;

            ecap@48300100 {
                compatible = <span class="string">"ti,am33xx-ecap"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48300100 0x80&gt;;
                ti,hwmods = <span class="string">"ecap0"</span>;
                status = <span class="string">"okay"</span>;
                linux,phandle = &lt;0x3f&gt;;
                phandle = &lt;0x3f&gt;;
            };

            ehrpwm@48300200 {
                compatible = <span class="string">"ti,am33xx-ehrpwm"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48300200 0x80&gt;;
                ti,hwmods = <span class="string">"ehrpwm0"</span>;
                status = <span class="string">"disabled"</span>;
            };
        };

        epwmss@48302000 {
            compatible = <span class="string">"ti,am33xx-pwmss"</span>;
            reg = &lt;0x48302000 0x10&gt;;
            ti,hwmods = <span class="string">"epwmss1"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            status = <span class="string">"okay"</span>;
            ranges = &lt;0x48302100 0x48302100 0x80 0x48302180 0x48302180 0x80 0x48302200 0x48302200 0x80&gt;;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x37 0x38&gt;;

            ecap@48302100 {
                compatible = <span class="string">"ti,am33xx-ecap"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48302100 0x80&gt;;
                ti,hwmods = <span class="string">"ecap1"</span>;
                status = <span class="string">"disabled"</span>;
            };

            ehrpwm@48302200 {
                compatible = <span class="string">"ti,am33xx-ehrpwm"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48302200 0x80&gt;;
                ti,hwmods = <span class="string">"ehrpwm1"</span>;
                status = <span class="string">"okay"</span>;
                linux,phandle = &lt;0x3e&gt;;
                phandle = &lt;0x3e&gt;;
            };
        };

        epwmss@48304000 {
            compatible = <span class="string">"ti,am33xx-pwmss"</span>;
            reg = &lt;0x48304000 0x10&gt;;
            ti,hwmods = <span class="string">"epwmss2"</span>;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            status = <span class="string">"disabled"</span>;
            ranges = &lt;0x48304100 0x48304100 0x80 0x48304180 0x48304180 0x80 0x48304200 0x48304200 0x80&gt;;

            ecap@48304100 {
                compatible = <span class="string">"ti,am33xx-ecap"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48304100 0x80&gt;;
                ti,hwmods = <span class="string">"ecap2"</span>;
                status = <span class="string">"disabled"</span>;
            };

            ehrpwm@48304200 {
                compatible = <span class="string">"ti,am33xx-ehrpwm"</span>;
                <span class="comment">#pwm-cells = &lt;0x3&gt;;</span>
                reg = &lt;0x48304200 0x80&gt;;
                ti,hwmods = <span class="string">"ehrpwm2"</span>;
                status = <span class="string">"disabled"</span>;
            };
        };

        ethernet@4a100000 {
            compatible = <span class="string">"ti,cpsw"</span>;
            ti,hwmods = <span class="string">"cpgmac0"</span>;
            cpdma_channels = &lt;0x8&gt;;
            ale_entries = &lt;0x400&gt;;
            bd_ram_size = &lt;0x2000&gt;;
            no_bd_ram = &lt;0x0&gt;;
            rx_descs = &lt;0x40&gt;;
            mac_control = &lt;0x20&gt;;
            slaves = &lt;0x2&gt;;
            active_slave = &lt;0x0&gt;;
            cpts_clock_mult = &lt;0x80000000&gt;;
            cpts_clock_shift = &lt;0x1d&gt;;
            reg = &lt;0x4a100000 0x800 0x4a101200 0x100&gt;;
            <span class="comment">#address-cells = &lt;0x1&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            interrupt-parent = &lt;0x1&gt;;
            interrupts = &lt;0x28 0x29 0x2a 0x2b&gt;;
            ranges;
            pinctrl-names = <span class="string">"default"</span>, <span class="string">"sleep"</span>;
            pinctrl-0 = &lt;0x39&gt;;
            pinctrl-1 = &lt;0x3a&gt;;

            mdio@4a101000 {
                compatible = <span class="string">"ti,davinci_mdio"</span>;
                <span class="comment">#address-cells = &lt;0x1&gt;;</span>
                <span class="comment">#size-cells = &lt;0x0&gt;;</span>
                ti,hwmods = <span class="string">"davinci_mdio"</span>;
                bus_freq = &lt;0xf4240&gt;;
                reg = &lt;0x4a101000 0x100&gt;;
                pinctrl-names = <span class="string">"default"</span>, <span class="string">"sleep"</span>;
                pinctrl-0 = &lt;0x3b&gt;;
                pinctrl-1 = &lt;0x3c&gt;;
                linux,phandle = &lt;0x3d&gt;;
                phandle = &lt;0x3d&gt;;
            };

            slave@4a100200 {
                mac-address = [00 00 00 00 00 00];
                phy_id = &lt;0x3d 0x0&gt;;
                phy-mode = <span class="string">"mii"</span>;
            };

            slave@4a100300 {
                mac-address = [00 00 00 00 00 00];
                phy_id = &lt;0x3d 0x1&gt;;
                phy-mode = <span class="string">"mii"</span>;
            };

            cpsw-phy-sel@44e10650 {
                compatible = <span class="string">"ti,am3352-cpsw-phy-sel"</span>;
                reg = &lt;0x44e10650 0x4&gt;;
                reg-names = <span class="string">"gmii-sel"</span>;
            };
        };

        ocmcram@40300000 {
            compatible = <span class="string">"ti,am3352-ocmcram"</span>;
            reg = &lt;0x40300000 0x10000&gt;;
            ti,hwmods = <span class="string">"ocmcram"</span>;
        };

        wkup_m3@44d00000 {
            compatible = <span class="string">"ti,am3353-wkup-m3"</span>;
            reg = &lt;0x44d00000 0x4000 0x44d80000 0x2000&gt;;
            ti,hwmods = <span class="string">"wkup_m3"</span>;
            ti,no-reset-on-init;
        };

        elm@48080000 {
            compatible = <span class="string">"ti,am3352-elm"</span>;
            reg = &lt;0x48080000 0x2000&gt;;
            interrupts = &lt;0x4&gt;;
            ti,hwmods = <span class="string">"elm"</span>;
            status = <span class="string">"disabled"</span>;
        };

        lcdc@4830e000 {
            compatible = <span class="string">"ti,am33xx-tilcdc"</span>;
            reg = &lt;0x4830e000 0x1000&gt;;
            interrupt-parent = &lt;0x1&gt;;
            interrupts = &lt;0x24&gt;;
            ti,hwmods = <span class="string">"lcdc"</span>;
            status = <span class="string">"okay"</span>;
        };

        tscadc@44e0d000 {
            compatible = <span class="string">"ti,am3359-tscadc"</span>;
            reg = &lt;0x44e0d000 0x1000&gt;;
            interrupt-parent = &lt;0x1&gt;;
            interrupts = &lt;0x10&gt;;
            ti,hwmods = <span class="string">"adc_tsc"</span>;
            status = <span class="string">"okay"</span>;

            tsc {
                compatible = <span class="string">"ti,am3359-tsc"</span>;
            };

            adc {
                <span class="comment">#io-channel-cells = &lt;0x1&gt;;</span>
                compatible = <span class="string">"ti,am3359-adc"</span>;
                ti,adc-channels = &lt;0x4 0x5 0x6&gt;;
            };
        };

        gpmc@50000000 {
            compatible = <span class="string">"ti,am3352-gpmc"</span>;
            ti,hwmods = <span class="string">"gpmc"</span>;
            ti,no-idle-on-init;
            reg = &lt;0x50000000 0x2000&gt;;
            interrupts = &lt;0x64&gt;;
            gpmc,num-cs = &lt;0x7&gt;;
            gpmc,num-waitpins = &lt;0x2&gt;;
            <span class="comment">#address-cells = &lt;0x2&gt;;</span>
            <span class="comment">#size-cells = &lt;0x1&gt;;</span>
            status = <span class="string">"disabled"</span>;
        };

        sham@53100000 {
            compatible = <span class="string">"ti,omap4-sham"</span>;
            ti,hwmods = <span class="string">"sham"</span>;
            reg = &lt;0x53100000 0x200&gt;;
            interrupts = &lt;0x6d&gt;;
            dmas = &lt;0x2c 0x24&gt;;
            dma-names = <span class="string">"rx"</span>;
        };

        aes@53500000 {
            compatible = <span class="string">"ti,omap4-aes"</span>;
            ti,hwmods = <span class="string">"aes"</span>;
            reg = &lt;0x53500000 0xa0&gt;;
            interrupts = &lt;0x67&gt;;
            dmas = &lt;0x2c 0x6 0x2c 0x5&gt;;
            dma-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
        };

        mcasp@48038000 {
            compatible = <span class="string">"ti,am33xx-mcasp-audio"</span>;
            ti,hwmods = <span class="string">"mcasp0"</span>;
            reg = &lt;0x48038000 0x2000 0x46000000 0x400000&gt;;
            reg-names = <span class="string">"mpu"</span>, <span class="string">"dat"</span>;
            interrupts = &lt;0x50 0x51&gt;;
            interrupts-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
            status = <span class="string">"disabled"</span>;
            dmas = &lt;0x2c 0x8 0x2c 0x9&gt;;
            dma-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
        };

        mcasp@4803C000 {
            compatible = <span class="string">"ti,am33xx-mcasp-audio"</span>;
            ti,hwmods = <span class="string">"mcasp1"</span>;
            reg = &lt;0x4803c000 0x2000 0x46400000 0x400000&gt;;
            reg-names = <span class="string">"mpu"</span>, <span class="string">"dat"</span>;
            interrupts = &lt;0x52 0x53&gt;;
            interrupts-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
            status = <span class="string">"disabled"</span>;
            dmas = &lt;0x2c 0xa 0x2c 0xb&gt;;
            dma-names = <span class="string">"tx"</span>, <span class="string">"rx"</span>;
        };

        rng@48310000 {
            compatible = <span class="string">"ti,omap4-rng"</span>;
            ti,hwmods = <span class="string">"rng"</span>;
            reg = &lt;0x48310000 0x2000&gt;;
            interrupts = &lt;0x6f&gt;;
        };

        pwm_test_P9_14@0 {
            compatible = <span class="string">"pwm_test"</span>;
            pwms = &lt;0x3e 0x0 0x7a120 0x1&gt;;
            pwm-names = <span class="string">"PWM_P9_14"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x37&gt;;
            enabled = &lt;0x1&gt;;
            duty = &lt;0x0&gt;;
            status = <span class="string">"okay"</span>;
        };

        pwm_test_P9_16@0 {
            compatible = <span class="string">"pwm_test"</span>;
            pwms = &lt;0x3e 0x0 0x7a120 0x1&gt;;
            pwm-names = <span class="string">"PWM_P9_16"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x38&gt;;
            enabled = &lt;0x1&gt;;
            duty = &lt;0x0&gt;;
            status = <span class="string">"okay"</span>;
        };

        pwm_test_P9_42 {
            compatible = <span class="string">"pwm_test"</span>;
            pwms = &lt;0x3f 0x0 0x7a120 0x1&gt;;
            pwm-names = <span class="string">"PWM_P9_42"</span>;
            pinctrl-names = <span class="string">"default"</span>;
            pinctrl-0 = &lt;0x36&gt;;
            enabled = &lt;0x1&gt;;
            duty = &lt;0x0&gt;;
            status = <span class="string">"okay"</span>;
        };
    };

    leds {
        pinctrl-names = <span class="string">"default"</span>;
        pinctrl-0 = &lt;0x40&gt;;
        compatible = <span class="string">"gpio-leds"</span>;

        led@2 {
            label = <span class="string">"beaglebone:green:heartbeat"</span>;
            gpios = &lt;0x41 0x15 0x0&gt;;
            linux,default-trigger = <span class="string">"heartbeat"</span>;
            default-state = <span class="string">"off"</span>;
        };

        led@3 {
            label = <span class="string">"beaglebone:green:mmc0"</span>;
            gpios = &lt;0x41 0x16 0x0&gt;;
            linux,default-trigger = <span class="string">"mmc0"</span>;
            default-state = <span class="string">"off"</span>;
        };

        led@4 {
            label = <span class="string">"beaglebone:green:usr2"</span>;
            gpios = &lt;0x41 0x17 0x0&gt;;
            linux,default-trigger = <span class="string">"cpu0"</span>;
            default-state = <span class="string">"off"</span>;
        };

        led@5 {
            label = <span class="string">"beaglebone:green:usr3"</span>;
            gpios = &lt;0x41 0x18 0x0&gt;;
            linux,default-trigger = <span class="string">"mmc1"</span>;
            default-state = <span class="string">"off"</span>;
        };
    };

    fixedregulator@0 {
        compatible = <span class="string">"regulator-fixed"</span>;
        regulator-name = <span class="string">"vmmcsd_fixed"</span>;
        regulator-min-microvolt = &lt;0x325aa0&gt;;
        regulator-max-microvolt = &lt;0x325aa0&gt;;
        linux,phandle = &lt;0x2f&gt;;
        phandle = &lt;0x2f&gt;;
    };

    hdmi {
        compatible = <span class="string">"ti,tilcdc,slave"</span>;
        i2c = &lt;0x42&gt;;
        pinctrl-names = <span class="string">"default"</span>, <span class="string">"off"</span>;
        pinctrl-0 = &lt;0x43&gt;;
        pinctrl-1 = &lt;0x44&gt;;
        status = <span class="string">"okay"</span>;

        panel-info {
            bpp = &lt;0x10&gt;;
            ac-bias = &lt;0xff&gt;;
            ac-bias-intrpt = &lt;0x0&gt;;
            dma-burst-sz = &lt;0x10&gt;;
            fdd = &lt;0x10&gt;;
            sync-edge = &lt;0x1&gt;;
            sync-ctrl = &lt;0x1&gt;;
            raster-order = &lt;0x0&gt;;
            fifo-th = &lt;0x0&gt;;
            invert-pxl-clk;
        };
    };
};
</code></pre>
<h3 id="重启开机后执行的效果"><a href="#重启开机后执行的效果" class="headerlink" title="重启开机后执行的效果"></a>重启开机后执行的效果</h3><pre><code class="bash">root@IDEASK:/boot/dtbs<span class="comment"># ll /dev/ttyO*</span>
crw-rw---- 1 root tty     248, 0 Jan  1 00:00 /dev/ttyO0
crw-rw---- 1 root dialout 248, 1 Jan  1 00:02 /dev/ttyO1
crw-rw---- 1 root dialout 248, 2 Jan  1 00:03 /dev/ttyO2
crw-rw---- 1 root dialout 248, 4 Jan  1 00:04 /dev/ttyO4
crw-rw---- 1 root dialout 248, 5 Jan  1 00:06 /dev/ttyO5
</code></pre>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/02/01/arm-asm/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/02/01/arm-asm/" itemprop="url">
                  ARM指令和指令系统
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-02-01T11:59:58+08:00">
                2017-02-01
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-02-06
			16:40:58
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/ARM汇编基础/" itemprop="url" rel="index">
                    <span itemprop="name">ARM汇编基础</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/02/01/arm-asm/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/02/01/arm-asm/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <pre><code>指令是指示计算机某种操作的命令，指令的集合称为指令系统。指令系统的功能强弱很大程度上决定了这类计算机智能的高低，它集中地反应了微处理器的硬件功能和属性。
ARM指令在机器中的表示格式是用32位的二进制数表示。如ARM中有一条指令为
    ADDEQS  R0，R1，#8；
其二进制代码形式为：
31~28    |    27~25    |    24~21    |    20    |    19~16    |     15~12    |    11~0
0000    |    001        |    0100    |    1    |    0001    |    0000    |    0000 0000 1000
cond    |        opcode                    |    Rn        |    Rd        |    Op2

ARM指令格式一般如下：
&lt;opcode&gt;    {&lt;cond&gt;}{s}&lt;Rd&gt;，&lt;Rn&gt;{，&lt;OP2&gt;}
格式中&lt; &gt;的内容是必不可少的，{ }中的内容可忽略

&lt;opcode&gt;    表示操作码。如ADD表示算术加法
{&lt;cond&gt;}        表示指令执行的条件域。如EQ、NE等，缺省为AL。
{S}    决定指令的执行结果是否影响CPSR的值，使用该后缀则指令执行结果影响CPSR的值，否则不影响
&lt;Rd&gt;    表示目的寄存器
&lt;Rn&gt;    表示第一个操作数，为寄存器
&lt;op2&gt;    表示第二个操作数，可以是立即数。寄存器和寄存器移位操作数
</code></pre><h2 id="ARM指令后缀：S、！"><a href="#ARM指令后缀：S、！" class="headerlink" title="ARM指令后缀：S、！"></a>ARM指令后缀：S、！</h2><pre><code>S后缀：指令中使用S后缀时，指令执行后程序状态寄存器的条件标志位将被刷新，不使用S后缀时，指令执行后程序状态寄存器的条件标志将不会发生变化。S后缀常用于对条件进行测试，如是否有溢出，是否进位等，根据这些变化，就可以进行一些判断，如是否大于，相等，从而影响指令执行的顺序。
！后缀：如果指令地址表达式中不含！后缀，则基址寄存器中的地址值不会发生变化。加上此后缀后，基址寄存器中的值（指令执行后） =  指令执行前的值 + 地址偏移量
    （1）！后缀必须紧跟在地址表达式后面，而地址表达式要有明确的地址偏移量
    （2）！后缀不能用于R15（PC）的后面
    （3）当用在单个地址寄存器后面时，必须确信这个寄存器有隐性的偏移量，例如“STMDB  R1！，{R3，R5，R7}”。此时地址基址寄存器R1的隐性偏移量为4（一条指令占32位，即4个字节）
</code></pre><h2 id="指令的条件码：31-28位4个字节存储，共16个条件码"><a href="#指令的条件码：31-28位4个字节存储，共16个条件码" class="headerlink" title="指令的条件码：31-28位4个字节存储，共16个条件码"></a>指令的条件码：31-28位4个字节存储，共16个条件码</h2><pre><code>条件码            助记符后缀            标志                含义
0000            EQ                    Z置位                相等
0001            NE                    Z清零                不相等
0010            CS                    C置位                无符号数大于或等于
0011            CC                    C清零                无符号数小于
0100            MI                    N置位                负数
0101            PL                    N清零                正数或零
0110            VS                    V置位                溢出
0111            VC                    V清零                未溢出
1000            HI                    C置位 Z清零            无符号数大于
1001            LS                    C清零 Z置位            无符号数小于或等于
1010            GE                    N等于V                带符号数大于或等于
1011            LT                    N不等于V            带符号数小于
1100            GT                    Z清零且（N等于V）    带符号数大于
1101            LE                    Z置位或（N不等于V）    带符号数小于或等于
1110            AL                    忽略                无条件执行
</code></pre><h2 id="ARM指令分类：六大类"><a href="#ARM指令分类：六大类" class="headerlink" title="ARM指令分类：六大类"></a>ARM指令分类：六大类</h2><pre><code>ARM指令集可以分为数据处理指令，数据加载指令和存储指令，分支指令，程序状态寄存器（PSR）处理指令，协处理器指令和异常产生指令六大类。
</code></pre><h2 id="ARM指令的寻址方式：8类"><a href="#ARM指令的寻址方式：8类" class="headerlink" title="ARM指令的寻址方式：8类"></a>ARM指令的寻址方式：8类</h2><pre><code>ARM指令的寻址方式一般可以分为8类：立即数寻址，寄存器寻址，寄存器间接寻址，寄存器移位寻址，基址变址寻址，多寄存器寻址，相对寻址，堆栈寻址等
举例：
MOV    R0，#15            ；立即数15放入寄存器R0中
ADD    R0，R1，R2        ；R0 &lt;= R1+R2
LDR    R0，[R4]        ；R0 &lt;= [R4]（R4中存放的是一个指针变量，[ ]表示取改地址值指向的内容）
ADD    R0，R1，R2，LSL #1        ；R0 &lt;= R1+R2（R2左移一位后的值）
MOV    R0，R1，LSL R3    ；R0 &lt;= R1（R1左移R3位后）
LDR    R0，[R1，#4]    ；R0 &lt;= [R1+4]
LDR    R0，[R1，#4]!    ；R0 &lt;= [R1+4]，R1 &lt;= R1+4。同时更新基址
LDR    R0，[R1]，#4    ；R0 &lt;= [R1]，R1 &lt;= R1+4
LDR    R0，[R1，R2]    ；R0 &lt;= [R1+R2]
LDMIA    R0!，{R1 - R4}    ；R1 &lt;= [R0]、R1 &lt;= [R0+4]、R1 &lt;= [R0+8]、R1 &lt;= [R0+12]
BL        proc                ；跳转到子程序proc处执行，执行完毕后返回（L标记，带返回的跳转）。
STMFD    R13!，{R0 - R4}    ；R0-R4压栈，FD为满栈递减，地址从高到低，R13为SP堆栈指针
LDMFD    R13!，{R0 - R4}    ；R0-R4出栈，FD为满栈递减
</code></pre><h2 id="ARM寄存器数据处理指令："><a href="#ARM寄存器数据处理指令：" class="headerlink" title="ARM寄存器数据处理指令："></a>ARM寄存器数据处理指令：</h2><h3 id="1、数据处理指令机器编码格式："><a href="#1、数据处理指令机器编码格式：" class="headerlink" title="1、数据处理指令机器编码格式："></a>1、数据处理指令机器编码格式：</h3><pre><code>31~28    |    27~26    25    |    24~21    |    20    |    19~16    |     15~12    |    11~0
cond    |       00        I    |    opcode    |    S    |    Rn        |    Rd        |    Op2

    cond：指令执行的条件码
    I：用于区别第二操作数是立即数（I=1）还是寄存器移位（I=0）
    opcode：数据处理指令操作码
    S：用于设置条件码，S=0时，条件码不改变，S=1时，条件码根据具体指令的结果修改
    Rn：第一操作数寄存器
    Rd：目标寄存器
    Op2：第二操作数，该数可以是立即数或寄存器移位数
</code></pre><h3 id="2、数据传送指令：MOV-MVN"><a href="#2、数据传送指令：MOV-MVN" class="headerlink" title="2、数据传送指令：MOV  MVN"></a>2、数据传送指令：MOV  MVN</h3><pre><code>MOV    R1，R0        ；将寄存器R0的值传送到寄存器R1
MOV    PC，R14    ；将寄存器R14的值传送到PC，常用于子程序返回
MOV    R1，R0，LSL #3        ；将寄存器R0的值左移3位后传送到R1
MOV    R0，#5        ；将立即数5传送到寄存器R0
MVN    R0，#0        ；将立即数0按位取反后传送到寄存器R0中，完成后R0 = -1
MVN    R1，R2        ；将R2按位取反后，结果存到R1
</code></pre><h3 id="3、移位指令：LSL、LSR、ASR、ROR、RRX"><a href="#3、移位指令：LSL、LSR、ASR、ROR、RRX" class="headerlink" title="3、移位指令：LSL、LSR、ASR、ROR、RRX"></a>3、移位指令：LSL、LSR、ASR、ROR、RRX</h3><pre><code>MOV    R0，R1，LSL #1        ；寄存器R1左移一位后传送到R0
MOVS    R0，R1，LSL #1        ；寄存器R1左移一位后传送到R0，并更新状态标志位
MOVS    R0，R1，LSR #1        ；寄存器R1右移一位后传送到R0，并更新状态标志位
MOVS    R0，R1，ASR #1        ；寄存器R1算术右移一位后传送到R0，并更新状态标志位
                            ；算术右移，第一位符号位不变
MOV    R0，R1，ROR #1    ；寄存器R1循环右移一位后传送到R0
MOVS    R0，R1，RRX        ；寄存器R1循环右移一位后传送到R0，用C标志位作为最高位扩展
</code></pre><h3 id="4、算术指令：ADD、ADC、SUB、SBC、RSB、RSC"><a href="#4、算术指令：ADD、ADC、SUB、SBC、RSB、RSC" class="headerlink" title="4、算术指令：ADD、ADC、SUB、SBC、RSB、RSC"></a>4、算术指令：ADD、ADC、SUB、SBC、RSB、RSC</h3><pre><code>ADD    R0，R1，R2            ；寄存器R1和R2的值相加后传送到R0
ADD    R0，R1，#5            ；寄存器R1的值加上5后传送到R0
ADD    R0，R1，R2，LSL #2        ；寄存器R2左移两位后与R1相加，得到的结果传送到R0
ADD    R0，R1，R2，LSL R3    ；寄存器R2左移R3后与R1相加，得到的结果传送到R0
ADDS    R0，R2，R4            ；64位加，低位放在R0
ADC    R1，R3，R5            ；64位加，高位放在R1，注意要加上低位的进位
SUB    R0，R1，R2            ；寄存器R1和R2的值相减后传送到R0
SUB    R0，R1，#6            ；寄存器R1的值减6后传送到R0
SUB    R0，R1，R2，LSL #1        ；R1与寄存器R2左移一位后的值相减，得到的结果传送到R0
SUBS    R0，R2，R4            ；64位减，低位放在R0
SBC    R1，R3，R5            ；64位减，高位放在R1，注意要减去低位的借位    
RSB    R0，R1，R2            ；寄存器R2和R1的值相减后传送到R0，注意是R2-R1，方向相反
RSB    R0，R1，#6            ；6与寄存器R1的值相减后传送到R0
RSB    R0，R1，R2，LSL #1        ；寄存器R2左移一位后与R1相减，得到的结果传送到R0
RSC    R0，R1，R2            ；寄存器R2和R1的值相减，再减去借位后传送到R0
</code></pre><h3 id="5、逻辑运算指令：AND、ORR、EOR、BIC"><a href="#5、逻辑运算指令：AND、ORR、EOR、BIC" class="headerlink" title="5、逻辑运算指令：AND、ORR、EOR、BIC"></a>5、逻辑运算指令：AND、ORR、EOR、BIC</h3><pre><code>AND    R0，R0，#0xF        ；R0的值与0xF相位与后的值传送到R0
ORR    R0，R0，#9            ；R0的值与9相位与后的值传送到R0
EOR    R0，R0，#0xF        ；R0的值与0xF相异或后的值传送到R0
BIC        R0，R0，#9            ；位清除指令R0的第0位和第3位清零
</code></pre><h3 id="6、比较指令：CMP、CMN、TST、TEQ"><a href="#6、比较指令：CMP、CMN、TST、TEQ" class="headerlink" title="6、比较指令：CMP、CMN、TST、TEQ"></a>6、比较指令：CMP、CMN、TST、TEQ</h3><pre><code>CMP    R1，#10                ；将寄存器R1的值与10相减，并设置CPSR标志位
ADDGT    R0，R0，#5            ；如果R1&gt;10，则执行ADDGT指令，将R0加5
CMN    R0，R1                ；R0 - (-R1)，反值比较，影响CPSR标志位
CMN    R0，#10                ；R0 - (-10)，反值比较，影响CPSR标志位
TST        R1，#3                ；检查R1中第0位和第1位是否为1，根据结果更新条件标志位
TEQ    R1，R2                ；将寄存器R1的值与寄存器R2的值进行按位异或，
                            ；并根据结果设置CPSR的标志位
</code></pre><h3 id="7、乘法指令：MUL、MLA、SMULL、SMLAL、UMULL、UMLAL"><a href="#7、乘法指令：MUL、MLA、SMULL、SMLAL、UMULL、UMLAL" class="headerlink" title="7、乘法指令：MUL、MLA、SMULL、SMLAL、UMULL、UMLAL"></a>7、乘法指令：MUL、MLA、SMULL、SMLAL、UMULL、UMLAL</h3><pre><code>MUL    R0，R1，R2            ；R1和R2相乘的结果发送到R0
MULS    R0，R1，R2            ；R1和R2相乘的结果发送到R0，同时设置CPSR的相关条件标志位
MLA    R0，R1，R2，R3    ；R1和R2相乘的结果再加上R3后发送到R0
MLAS    R0，R1，R2，R3    ；R1和R2相乘的结果再加上R3后发送到R0，更新CPSR标志位
SMULL    R0，R1，R2，R3    ；R2和R3相乘的结果的低32位放在R0，高32位放在R1
SMLAL    R0，R1，R2，R3    ；R2和R3相乘的结果的低32位加上R0后放在R0，
                            ；高32位加上R1后放在R1
UMULL    R0，R1，R2，R3    ；无符号数相乘，结果与SMULL类似
UMLAL    R0，R1，R2，R3    ；无符号数乘加，结果与SMLAL类似
</code></pre><h2 id="ARM数据加载和存储指令："><a href="#ARM数据加载和存储指令：" class="headerlink" title="ARM数据加载和存储指令："></a>ARM数据加载和存储指令：</h2><h3 id="1、数据加载和存储的方向。寄存器到存储器方向：Store；从存储器到寄存器方向：Load"><a href="#1、数据加载和存储的方向。寄存器到存储器方向：Store；从存储器到寄存器方向：Load" class="headerlink" title="1、数据加载和存储的方向。寄存器到存储器方向：Store；从存储器到寄存器方向：Load"></a>1、数据加载和存储的方向。寄存器到存储器方向：Store；从存储器到寄存器方向：Load</h3><pre><code>数据加载和存储指令共有三种类型：单寄存器加载和存储指令，多寄存器加载和存储指令 和 交换指令
</code></pre><h3 id="2、数据加载与存储器指令寻址"><a href="#2、数据加载与存储器指令寻址" class="headerlink" title="2、数据加载与存储器指令寻址"></a>2、数据加载与存储器指令寻址</h3><pre><code>LDR    R5，[R6，#0x08]        ；R6寄存器加0x08的和的地址值内的数据传送到R5
STR        R6，[R7]，#-0x08    ；R6寄存器的数据传送到R7存储的地址值指向的存储空间，
                            ；同时更新R7寄存器的内容为R7-0x08
LDR    R5，[R6，R3]        ；R6寄存器加R3的和的地址值内的数据传送到R5
STR        R6，[R7]，-R8        ；R6寄存器的数据传送到R7存储的地址值指向的存储空间，
                            ；同时更新R7寄存器的内容为R7-R8
LDR    R3，[R2，R4，LSL #2]    ；R3 &lt;== [  R2 + R4(R4左移两位)  ]
LDR    R3，[R2]，-R4，LSR #3    ；R3 &lt;== [ R2 ]，R2 = R2-R4（R4右移三位）
LDR    R4，START            ；将标号START标定的空间的数据加载到R4中
</code></pre><h3 id="3、地址索引：前索引、自动索引、后索引"><a href="#3、地址索引：前索引、自动索引、后索引" class="headerlink" title="3、地址索引：前索引、自动索引、后索引"></a>3、地址索引：前索引、自动索引、后索引</h3><pre><code>1】前索引：前索引也称为前变址，这种索引是在指令执行前把偏移量和基址相加减，得到的值作为变量的地址。如：
LDR    R5，[R6，#0x04]
STR        R0，[R5，-R8]
2】自动索引：自动索引也称为自动变址，有时为了修改基址寄存器的内容，使之指向数据传送地址，可使用这种方法自动修改基址寄存器，如：
LDR    R5，[R6，#0x04]！
3】后索引：后索引也被称为后变址，后索引就是用基址寄存器的地址值寻址，找出操作数进行操作，操作完成后，再把地址偏移量和基址相加/减，结果送到基址寄存器，作为下一次寻址的基址。如：
LDR    R5，[R6]，#0x04
STR        R6，[R7]，#-0x08
</code></pre><h3 id="4、单寄存器加载和存储指令：LDR-STR、LDRB-STRB、LDRH-STRH、LDRSB-LDRSH"><a href="#4、单寄存器加载和存储指令：LDR-STR、LDRB-STRB、LDRH-STRH、LDRSB-LDRSH" class="headerlink" title="4、单寄存器加载和存储指令：LDR/STR、LDRB/STRB、LDRH/STRH、LDRSB/LDRSH"></a>4、单寄存器加载和存储指令：LDR/STR、LDRB/STRB、LDRH/STRH、LDRSB/LDRSH</h3><pre><code>1】字数据加载/存储指令格式：
    31~28    |  27~26    | 25 24 23 22 21 20|    19~16    |     15~12    |    11~0
    cond    |     01    |   I    P  U  B   W  L      |    Rn        |    Rd        |    Op2
    cond：指令执行的条件编码
    I、P、U、W：用于区别不同的地址模式（偏移量）。
        I为0时，偏移量为12位立即数；I为1时，偏移量为移位寄存器移位
        P表示前/后索引
        U表示加/减
        W表示回写
    L：L为1时表示加载，L为0时表示存储
    B：B为1表示字节访问，B为0表示字访问
    Rd：源/目标寄存器
    Rn：基址寄存器
    Op2：表示偏移量是一个12位的无符号二进制数，与Rn一起构成地址addr
2】存储器&lt;==&gt;寄存器  LDR/STR
    LDR指令用于从存储器中间一个32位的字数据加载到目的寄存器Rd中。该指令通常用于从存储器中读取32位的字数据到通用寄存器，然后对数据进行处理。当程序计数器PC作为目的寄存器时，指令从存储器中读取的字数据被当做目的地址，从而实现程序流程的跳转。
LDR    R4，START            ；将存储地址为START的字数据读入R4
STR        R5，DATA1            ；将R5存入存储地址为DATA1中
LDR    R0，[R1]            ；将存储器地址为R1的字数据读入寄存器R0
LDR    R0，[R1，R2]        ；将存储器地址为R1+R2的字数据读入寄存器R0
LDR    R0，[R1，#8]        ；将寄存器R1+8的内容读入寄存器R0
LDR    R0，[R1，R2，LSL #2]    ；将R1+R2*4的字数据读入寄存器R0
STR        R0，[R1，R2]!        ；将R0字数据存入存储器地址为R1+R2的存储单元中，
                                并将新地址R1+R2写入R1
STR        R0，[R1，#8]!        ；将R0字数据存入存储器地址为R1+8的存储单元中，
                                并将新地址R1+8写入R1
STR        R0，[R1，R2，LSL #2]!    ；将R0字数据存入地址为R1+R2*4的存储单元中，
                                并将新地址R1+R2*4写入R1
LDR    R0，[R1]，#8        ；将存储器地址为R1的字数据读入寄存器R0，
                                并将新地址R1+8写入R1
LDR    R0，[R1]，R2        ；将存储器地址为R1的字数据读入寄存器R0，
                                并将新地址R1+R2写入R1
LDR    R0，[R1]，R2，LSL #2    ；将存储器地址为R1的字数据读入寄存器R0，
                                并将新地址R1+R2*4写入R1
    【备注】注意事项：
    a、立即数绝对值不大于4095的数值，可使用带符号数，即在-4095 ~ +4095之间。（4096D = 1000H）
    b、语句的标号不能指向程序存储器的程序存储区，而是指向程序存储器的数据存储区或数据存储器的数据存储区。另外指向的区域是可修改的。例如，在用户模式下，有些存储区是不能访问的或是只读的。
    c、字传送时，偏移量必须保证偏移的结果能够使地址对齐。
    d、使用寄存器移位的方法计算偏移量时。移位的位数不能超过规定的数值，而且不能用寄存器表示移位的位数。各类移位指令的移位位数规定如下：
            ASR    #n：算术右移（1≤n≤32）
            LSL        #n：逻辑左移（0≤n≤31）
            LSR        #n：逻辑右移（1≤n≤32）
            ROR    #n：循环右移（1≤n≤31）
    e、R15作为基址寄存器Rn时，不可以使用回写功能，即使用后缀“!”，另外，R15不可作为偏移寄存器使用。
</code></pre><h3 id="5、字节数据加载-存储指令：LDRB-STRB"><a href="#5、字节数据加载-存储指令：LDRB-STRB" class="headerlink" title="5、字节数据加载/存储指令：LDRB/STRB"></a>5、字节数据加载/存储指令：LDRB/STRB</h3><pre><code>LDRB指令用于从存储器中将一个8位字节的数据加载到目的寄存器，同时将寄存器的高24位清零。该指令通常用于从存储器中读取8位的字节数据到通用寄存器，然后对数据进行处理。当程序计数器PC作为目的寄存器时，指令从存储器读取的数据被当做目的地，从而可以实现程序流程的跳转
STRB指令用于从源寄存器中将一个8位的字节数据存储到存储器中，该字节数据为源寄存器的低8位，STRB指令和LDRB指令的区别在于数据的传送方向。
LDRB    R0，[R1]            ；将存储器地址为R1的字节数据读入寄存器R0，
                                并将R0的高24位清零。
LDRB    R0，[R1，#8]        ；将存储器地址为R1+8的字节数据读入寄存器R0，
                                并将R0的高24位清零。
STRB    R0，[R1]            ；将寄存器R0中的字节数据写入以R1为地址的存储器中。
STRB    R0，[R1，#8]        ；将寄存器R0中的字节数据写入以R1+8为地址的存储器中。
</code></pre><h3 id="6、LDRH-STRH-半字数据加载-存储指令"><a href="#6、LDRH-STRH-半字数据加载-存储指令" class="headerlink" title="6、LDRH/STRH 半字数据加载/存储指令"></a>6、LDRH/STRH 半字数据加载/存储指令</h3><pre><code>    31~28|  27~25| 24 23 22 21 20 |    19~16| 15~12| 11~8      | 7   6   5   4   | 3~0
    cond   |     000  |  P  U    I   W   L  |        Rn   |     Rd    | addr_H  |1    S   H   1    |addr_L
    cond：指令执行的条件编码
    I、P、U、W：用于区别不同的地址模式（偏移量）。I为0时，偏移量为8位立即数，I为1时，偏移量为寄存器移位。P表示前/后变址，U表示加/减，W表示回写。
    L：L为1表示加载，L为0表示存储。
    S：用于区别有符号访问（S为1）和无符号访问（S为0）
    H：用于区别半字访问（H为1）或字节访问（H为0）
    Rd：源/目标寄存器
    Rn：基址寄存器
    addr  H / addr  I：表示偏移量，I为0时，偏移量为8位立即数由addr  H和addr  I组成；
    I为1时，偏移量为寄存器移位addr  H为0，addr  L表示寄存器编号
LDR指令用于从寄存器中间一个16位的半字数据加载到目的寄存器Rd中，同时将寄存器的高16位清零，该指令通常用于从存储器中读取16位的半字数据到通用寄存器，然后对数据进行处理。当程序计数器PC作为目的寄存器时，指令从存储器中读取的数据被当做目的地址，从而可以实现程序流程的跳转。
LDRH    R0，[R1]            ；将存储器地址R1的半字数据读入寄存器R0，
                                并将R0的高16位清零
LDRH    R0，[R1，#8]        ；将存储器地址为R1+8的半字数据读入寄存器R0，
                                并将R0的高16位清零
LDRH    R0，[R1，R2]        ；将存储器地址为R1+R2的半字数据读入寄存器R0，
                                并将R0的高16位清零
STRH    R0，[R1]            ；将寄存器R0中的半字数据写入以R1为地址的存储器中
使用半字加载/存储指令需要注意的事项：
（1）必须半字地址对齐。
（2）对于R15的使用需要慎重，R15作为基址寄存器Rn时，不可以使用回写功能，不可使用R15作为目的寄存器。
（3）立即数偏移使用的是8位无符号数。
（4）不能使用寄存器移位寻址
</code></pre><h3 id="7、有符号数字节-半字加载指令：LDRSB-LDRSH"><a href="#7、有符号数字节-半字加载指令：LDRSB-LDRSH" class="headerlink" title="7、有符号数字节/半字加载指令：LDRSB / LDRSH"></a>7、有符号数字节/半字加载指令：LDRSB / LDRSH</h3><pre><code>LDRSB指令用于从存储器中间一个8位的字节数据加载到目的寄存器中，同时将寄存器的高24位设置为该字节数据的符号位的值，即将该8位字节数据进行符号位的扩展，生成32位数据；LDRSH指令用于从存储器中将一个16位的半字数据加载到目的寄存器Rd中，同时将寄存器的高16位设置为该字数据的符号位的值，即将该16位字数据进行符号位的扩展，生成32位数据。
LDRSB    R0，[R1，#4]        ；将存储地址为R1+4的有符号字节数据读入R0，
                                R0中的高24位设置为高字节数据的符号位
LDRSH    R6，[R2]，#2        ；将存储地址为R2+2的有符号半字数据读入R6，
                                R6的高16位设置成该字节数据的符号位，R2=R2+2
</code></pre><h3 id="8、多寄存器加载和存储指令：LDM-STM"><a href="#8、多寄存器加载和存储指令：LDM-STM" class="headerlink" title="8、多寄存器加载和存储指令：LDM / STM"></a>8、多寄存器加载和存储指令：LDM / STM</h3><pre><code>LDM指令用于从基址寄存器所指示的一片连续存储器中读取数据到寄存器列表所指示的多个寄存器中，内存单元的其实地址为基址寄存器Rn的值，各个寄存器有寄存器列表regs表示。该指令一般用于多个寄存器数据的出栈操作；STM指令用于将寄存器列表所指示的多个寄存器的值存入到由基址寄存器所指示的一片连续存储器中，内存单元的其实地址为基址寄存器Rn的值，各个寄存器由寄存器列表regs表示。指令的其它参数的用法和LDM指令是相同的。该指令一般用于多个寄存器数据的进栈操作。
type类型。用于数据的存储和读取有一下几种情况：
        IA        每次传送后地址值加
        IB        每次传送前地址值加
        DA        每次传送后地址值减
        DB        每次传送前地址值减
对于堆栈操作有如下几种情况：
        FD        满递减堆栈
        ED        空递减堆栈
        FA        满递增堆栈
        EA        满递增堆栈

{ ! }为可选后缀，若选用该后缀，则当数据加载与存储完毕后，将最后的地址写入基址寄存器，否则基址寄存器的内容不改变。基址寄存器不允许为R15，寄存器列表可以为R0~R15的任意组合。
{ ^ }为可选后缀，当治疗为LDM且寄存器列表中包含R15，选用该后缀时表示：除了正常数据加载和存储之外，还将SPSR复制到CPSR。同时，该后缀还表示传入或传出的是用户模式下的寄存器，而不是当前模式下的寄存器。
LDMIA    R0!，{R6-R8}        ；R6 &lt;- [R0]，R7 &lt;- [R0+4]，R8 &lt;- [R0+8]，R0 &lt;- R0+12
LDMIB    R0!，{R6-R8}        ；R6 &lt;- [R0]，R7 &lt;- [R0+4]，R8 &lt;- [R0+8]，R0 &lt;- R0+8
</code></pre><h3 id="9、堆栈和堆栈操作"><a href="#9、堆栈和堆栈操作" class="headerlink" title="9、堆栈和堆栈操作"></a>9、堆栈和堆栈操作</h3><pre><code>堆栈就是在RAM存储器中开辟（指定）的一个特定的存储区域，在这个区域中，信息的存入（此时称为推入）与取出（此时称为弹出）的原则不再是“随机存取”，而是按照“后进先出”的原则就行存取。
A】建栈：规定堆栈底部在RAM存储器中的位置，如：用户可以通过LDR命令设置SP的值来建立堆栈。
LDR    R13，=0x90010        ；
LDR    SP，=0x90010        ；
这时，SP指向地址0x90010，栈内无数据，堆栈底部与顶部重叠，是一个空栈。
B】进栈：STM指令配合FD（满递减）、ED（空递减）、FA（满递增）、EA（空递增）完成入栈操作。在使用一个堆栈的时候，需要确定堆栈在存储器空间中是向上生长还是向下生长的。向上称为递增，向下称为递减。
STMFD    SP!，{R2-R4}        ；把R4，R3，R2的值依次压栈（标号高的存在高地址）
LDMFD    SP!，{R6-R8}        ；把R2，R3，R4的值，依次退到R6，R7，R8
</code></pre>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/26/Pipeline-architecture/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/26/Pipeline-architecture/" itemprop="url">
                  ARM获得当前PC需要PC=PC+8？
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-26T10:23:24+08:00">
                2017-01-26
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-26
			10:23:24
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/ARM体系架构/" itemprop="url" rel="index">
                    <span itemprop="name">ARM体系架构</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/26/Pipeline-architecture/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/26/Pipeline-architecture/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="ARM获得当前PC需要PC-PC-8？"><a href="#ARM获得当前PC需要PC-PC-8？" class="headerlink" title="ARM获得当前PC需要PC=PC+8？"></a>ARM获得当前PC需要PC=PC+8？</h1><h2 id="1、抛出问题"><a href="#1、抛出问题" class="headerlink" title="1、抛出问题"></a>1、抛出问题</h2><pre><code>为何ARM9和ARM7一样？一个是五级流水线结构，另外一个是三级流水线结构，怎么也是PC=PC+8？ 
</code></pre><h3 id="ARM9五级流水线-VS-ARM7三级流水线"><a href="#ARM9五级流水线-VS-ARM7三级流水线" class="headerlink" title="ARM9五级流水线 VS ARM7三级流水线"></a>ARM9五级流水线 VS ARM7三级流水线</h3><p><img src="http://my.csdn.net/uploads/201207/08/1341755975_5410.png" alt="这里写图片描述"></p>
<h3 id="对应的映射关系"><a href="#对应的映射关系" class="headerlink" title="对应的映射关系"></a>对应的映射关系</h3><p><img src="http://my.csdn.net/uploads/201207/08/1341755957_7798.png" alt="这里写图片描述"></p>
<h2 id="2、解析问题"><a href="#2、解析问题" class="headerlink" title="2、解析问题"></a>2、解析问题</h2><h3 id="先列出ARM9的五级流水线的示例："><a href="#先列出ARM9的五级流水线的示例：" class="headerlink" title="先列出ARM9的五级流水线的示例："></a>先列出ARM9的五级流水线的示例：</h3><p><img src="http://my.csdn.net/uploads/201207/08/1341755941_1321.jpg" alt="这里写图片描述"><br>以uboot中的start.S的最开始的汇编代码为例来进行解释：<br>由反汇编可得：</p>
<pre><code class="bash">00000000 &lt;_start&gt;:
   0:   ea000014   b   58 &lt;reset&gt;
   4:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 20 &lt;_undefined_instruction&gt;</span>
   8:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 24 &lt;_software_interrupt&gt;</span>
   c:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 28 &lt;_prefetch_abort&gt;</span>
  10:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 2c &lt;_data_abort&gt;</span>
  14:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 30 &lt;_not_used&gt;</span>
  18:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 34 &lt;_irq&gt;</span>
  1c:   e59ff014   ldr pc, [pc, <span class="comment">#20] ; 38 &lt;_fiq&gt;</span>

00000020 &lt;_undefined_instruction&gt;:
  20:   00000120   .word  0x00000120
</code></pre>
<p>下面对每一个指令周期，CPU做了哪些事情，分别详细进行阐述：<br>在看下面具体解释之前，有一句话要牢记，那就是：</p>
<pre><code class="bash">PC不是指向你正在运行的指令，而是
PC始终指向你要取的指令的地址。
</code></pre>
<p>认识清楚了这个前提，后面的举例讲解，就容易懂了。<br>指令周期Cycle1<br>（1）取指：<br>PC总是指向将要读取的指令的地址（即我们常说的，指向下一条指令的地址），而当前PC=4，<br>所以去取物理地址为4对对应的指令“ldr pc, [pc, #20]”，其对应二进制代码为e59ff014。<br>此处取指完之后，自动更新PC的值，即PC=PC+4（单个指令占4字节，所以加4）=4+4=8<br>指令周期Cycle2<br>（1）译指：翻译指令e59ff014；<br>（2）同时再去取指：<br>PC总是指向将要读取的指令的地址（即我们常说的，指向下一条指令的地址），而当前PC=8，<br>所以去物理地址为8所对应的指令“ldr pc, [pc, #20]” 其对应二进制代码为e59ff014。<br>此处取指完之后，自动更新PC的值，即PC=PC+4=8+4=12=0xc<br>指令周期Cycle3<br>（1）执行（指令）：执行“e59ff014”，即“ldr pc,[pc, #20]”所对表达的含义，即<br>PC<br>= PC + 20<br>= 12 + 20<br>= 32<br>= 0x20<br>此处，只是计算出待会要赋值给PC的值是0x20，这个0x20还只是放在执行单元中内部的缓冲中。<br>（2）译指：翻译e59ff014。<br>（3）取指：<br>此步骤由于是和上面（1）中的执行同步做的，所以，未受到影响，继续取指，而取指的那一时刻，PC为上一Cycle<br>更新后的值，即PC=0xc，所以是去取物理地址为0xc所对应的指令” ldr pc, [pc, #20]”，对应二进制为e59ff014。<br>其实，分析到这里，大家就可以看出：<br>在Cycle3的时候，PC的值，刚好已经在Cycle1和Cycle2，分别加了4，所以Cycle3的时候，PC=PC+8，而同样道理<br>，对于任何一条指令的，都是在Cycle3，指令的Execute执行阶段，如果用到PC的值，那么PC那一时刻，就是<br>PC=PC+8。<br>所以，此处虽然是五级流水线，但是却不是PC=PC+16，而是PC=PC+8。<br>进一步地，我们发现，其实PC=PC+N的N，是和指令的执行阶段所处于流水线的深度有关，即此处指令的执行<br>Execute阶段，是五级流水线中的第三个，而这个第三阶段的Execute和指令的第一个阶段的Fetch取指，相差的<br>值是 3 -1 =2，即两个CPU的Cycle，而每个Cycle都会导致PC=+PC+4，所以，指令到了Execute阶段，才会发现<br>，此时PC已经变成PC=PC+8了。<br>回过头来反观ARM7的三级流水线，也是同样的道理，指令的Execute执行阶段，是处于指令的第三个阶段，<br>同理，在指令计算数据的时候，如果用到PC，就会发现此时PC=PC+8。<br>同理，假如ARM9的五级流水线，把指令的Execute执行阶段，设计在了第四个阶段，那么就是<br>PC=PC+（第4阶段-1）*4个字节 = PC= PC+12了。</p>
<h2 id="3、总结"><a href="#3、总结" class="headerlink" title="3、总结"></a>3、总结</h2><p>ARM7的三级流水线，PC=PC+8，<br>ARM9的五级流水线，也是PC=PC+8，<br>根本的原因是，两者的流水线设计中，指令的Execute执行阶段，都是处于流水线的第三级，<br>所以使得PC=PC+8。<br>类似地，可以推导出：<br>假设，Execute阶段处于流水线中的第E阶段，每条指令是T个字节，那么<br>PC<br>= PC + N<em>T<br>= PC + (E - 1) </em> T<br>此处ARM7和ARM9：<br>Execute阶段都是第3阶段-&gt; E=3<br>每条指令是4个字节-&gt; T=4<br>所以：<br>PC<br>=PC + N<em> T<br>=PC + (3 -1 ) </em> 4<br>= PC + 8</p>
<h2 id="关于直接改变PC的值，会导致流水线清空的解释"><a href="#关于直接改变PC的值，会导致流水线清空的解释" class="headerlink" title="关于直接改变PC的值，会导致流水线清空的解释"></a>关于直接改变PC的值，会导致流水线清空的解释</h2><p>   把PC的值直接赋值为0x20。而PC值更改，直接导致流水线的清空，即导致下一个cycle中的，对应的流水线中的<br>其他几个步骤，包括接下来的同一个Cycle中的取指的工作被取消。在PC跳转到0x20的位置之后，流水线重新计算<br>，重新一步步地按照流水线的逻辑，去一点点执行。当然要保证当前指令的执行完成，即执行之后，<br>还有两个cycle，分别做的Memory和Write，会继续执行完成。</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/23/embedded-system-learning/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/23/embedded-system-learning/" itemprop="url">
                  嵌入式linux系统开发学习路径
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-23T11:22:33+08:00">
                2017-01-23
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-23
			11:22:33
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/学习路线/" itemprop="url" rel="index">
                    <span itemprop="name">学习路线</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/23/embedded-system-learning/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/23/embedded-system-learning/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="嵌入式linux系统开发学习路径"><a href="#嵌入式linux系统开发学习路径" class="headerlink" title="嵌入式linux系统开发学习路径"></a>嵌入式linux系统开发学习路径</h1><hr>
<p>　  ## 一：C语言<br>　　嵌入式Linux工程师的学习需要具备一定的C语言基础，C语言是嵌入式领域最重要也是最主要的编程语言，通过大量编程实例重点理解C语言的基础编程以及高级编程知识。包括：基本数据类型、数组、指针、结构体、链表、文件操作、队列、栈等。</p>
<p>　　## 二：Linux基础<br>　　Linux操作系统的概念、安装方法，详细了解Linux下的目录结构、基本命令、编辑器VI ,编译器GCC，调试器GDB和 Make 项目管理工具, Shell Makefile脚本编写等知识，嵌入式开发环境的搭建。</p>
<p>　　## 三：Linux系统编程<br>　　重点学习标准I/O库，Linux多任务编程中的多进程和多线程，以及进程间通信(pipe、FIFO、消息队列、共享内存、signal、信号量等)，同步与互斥对共享资源访问控制等重要知识，主要提升对Linux应用开发的理解和代码调试的能力。</p>
<p>　　## 四：Linux网络编程<br>　　计算机网络在嵌入式Linux系统应用开发过程中使用非常广泛，通过Linux网络发展、TCP/IP协议、socket编程、TCP网络编程、UDP网络编程、Web编程开发等方面入手，全面了解Linux网络应用程序开发。重点学习网络编程相关API，熟练掌握TCP协议服务器的编程方法和并发服务器的实现，了解HTTP协议及其实现方法，熟悉UDP广播、多播的原理及编程方法，掌握混合C/S架构网络通信系统的设计，熟悉HTML,Javascript等Web编程技术及实现方法。</p>
<p>　　## 五：数据结构与算法<br>　　数据结构及算法在嵌入式底层驱动、通信协议、及各种引擎开发中会得到大量应用，对其掌握的好坏直接影响程序的效率、简洁及健壮性。此阶段的学习要重点理解数据结构与算法的基础内容，包括顺序表、链表、队列、栈、树、图、哈希表、各种查找排序算法等应用及其C语言实现过程。</p>
<p>　　## 六：C++ 、QT<br>　　C++是Linux应用开发主要语言之一，本阶段重点掌握面向对象编程的基本思想以及C++的重要内容。图形界面编程是嵌入式开发中非常重要的一个环节。由于QT具有跨平台、面向对象、丰富API、支持2D/3D渲染、支持XML、多国语等强大功能，在嵌入式领域的GUI开发中得到了广范的应用，在本阶段通过基于QT图形库的学习使学员可以熟练编写GUI程序，并移植QT应用程序到Cortex-A8平台。包括IDE使用、QT部件及布局管理器、信息与槽机制的应用、鼠标、键盘及绘图事件处理及文件处理的应用。</p>
<p>　　## 七：Cortex A8 、Linux 平台开发<br>　　通过基于ARM Cortex-A8处理s5pv210了解芯片手册的基本阅读技巧，掌握s5pv210系统资源、时钟控制器、电源管理、异常中断控制器、nand flash控制器等模块，为底层平台搭建做好准备。Linux平台包括内核裁减、内核移植、交叉编译、GNU工具使用、内核调试、Bootloader介绍、制作与原理分析、根文件系统制作以及向内核中添加自己的模块，并在s5pv210实验平台上运行自己制作的Linux系统,集成部署Linux系统整个流程。同时了解Android操作系统开发流程。Android系统是基于Linux平台的开源操作系统，该平台由操作系统、中间件、用户界面和应用软件组成，是首个为移动终端打造的真正开放和完整的移动软件，目前它的应用不再局限于移动终端，还包括数据电视、机顶盒、PDA等消费类电子产品。</p>
<p>　　## 八：驱动开发<br>　　驱动程序设计是嵌入式Linux开发工作中重要的一部分，也是比较困难的一部分。本阶段的学习要熟悉Linux的内核机制、驱动程序与用户级应用程序的接口，掌握系统对设备的并发操作。熟悉所开发硬件的工作原理，具备ARM硬件接口的基础知识，熟悉ARM Cortex-A8处理器s5pv210各资源、掌握Linux设备驱动原理框架，熟悉工程中常见Linux高级字符设备、块设备、网络设备、USB设备等驱动开发，在工作中能独立胜任底层驱动开发。</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/23/gdb-transplant/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/23/gdb-transplant/" itemprop="url">
                  gdb移植和使用方法
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-23T11:13:48+08:00">
                2017-01-23
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-23
			11:13:48
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/gdb/" itemprop="url" rel="index">
                    <span itemprop="name">gdb</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/23/gdb-transplant/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/23/gdb-transplant/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="gdb移植和使用方法"><a href="#gdb移植和使用方法" class="headerlink" title="gdb移植和使用方法"></a>gdb移植和使用方法</h1><hr>
<h2 id="1、gdb移植"><a href="#1、gdb移植" class="headerlink" title="1、gdb移植"></a>1、gdb移植</h2><pre><code class="bash"><span class="comment">#./configure --target=arm-linux --host=arm-linux</span>
<span class="comment">#make CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc</span>
</code></pre>
<h2 id="2、gdb使用"><a href="#2、gdb使用" class="headerlink" title="2、gdb使用"></a>2、gdb使用</h2><h3 id="2-1、gdb网络调试"><a href="#2-1、gdb网络调试" class="headerlink" title="2.1、gdb网络调试"></a>2.1、gdb网络调试</h3><p>先nfs挂载先<br>开发板：</p>
<pre><code class="bash">gdbserver [电脑的IP地址：端口号] [待调试的程序]
</code></pre>
<p>电脑：</p>
<pre><code class="bash">gdb
target remote [开发板IP地址：端口号]
</code></pre>
<h3 id="2-2、gdb串口调试"><a href="#2-2、gdb串口调试" class="headerlink" title="2.2、gdb串口调试"></a>2.2、gdb串口调试</h3><p>配置串口调试的设置：<br>在xxx-linux-gdb里敲入入下命令：</p>
<pre><code class="bash"><span class="built_in">set</span> remotedevice /dev/ttyS0（这里设置串口1）
<span class="built_in">set</span> remote baud 9600 （这里设置串口波特率）
<span class="built_in">set</span> debug remote 1(可选)
target remote /dev/ttyS0
</code></pre>
<p>如果你用串口1调试hello的话，你就要现在板子上运行命令：</p>
<pre><code class="bash">gdbserver hello /dev/ttyS0 （详情可以参考gdbserver目录下的readme文件）
</code></pre>
<p>这时gdbserver就在等待gdb的应答信号了。<br>然后在pc机上运行命令：</p>
<pre><code class="bash">xxx-linux-gdb hello
</code></pre>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/23/gcc-static-dynamic/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/23/gcc-static-dynamic/" itemprop="url">
                  gcc静态编译和动态编译笔记
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-23T11:08:43+08:00">
                2017-01-23
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-23
			11:08:43
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/gcc笔记/" itemprop="url" rel="index">
                    <span itemprop="name">gcc笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/23/gcc-static-dynamic/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/23/gcc-static-dynamic/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="gcc静态编译与动态编译"><a href="#gcc静态编译与动态编译" class="headerlink" title="gcc静态编译与动态编译"></a>gcc静态编译与动态编译</h1><h2 id="1、静态库"><a href="#1、静态库" class="headerlink" title="1、静态库"></a>1、静态库</h2><p>gcc -c 编译出目标文件 ，而不是直接gcc  直接gcc系统会直接链接目标文件，但是由于缺少main函数所以不成功<br>ar归档工具生成静态库<br>-c 建立备存文件<br>-r 将文件插入备存文件<br>-v 显示执行过程<br>-s 无论ar命令是否修改了库内容都强制重新生成库符号表<br>ar rcvs [libpow.a静态库文件] [unsgn_pow.o 目标文件]<br>将目标文件集合在一起</p>
<h2 id="2、动态库"><a href="#2、动态库" class="headerlink" title="2、动态库"></a>2、动态库</h2><p>gcc -c -fPIC -Wall unsgn_pow.c<br>gcc -shared -o libpow.so unsgn_pow.o<br>gcc -o pow_test pow_test.c -L . -lpow</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/23/vim-note/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/23/vim-note/" itemprop="url">
                  vim笔记
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-23T10:58:22+08:00">
                2017-01-23
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-23
			10:58:22
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/编程工具笔记/" itemprop="url" rel="index">
                    <span itemprop="name">编程工具笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/23/vim-note/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/23/vim-note/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="VIM工具常用快捷键"><a href="#VIM工具常用快捷键" class="headerlink" title="VIM工具常用快捷键"></a>VIM工具常用快捷键</h1><hr>
<p>G 到文件最底部<br>gg 到文件顶部<br>V  行复制框选<br>v  字符复制框选<br>ctrl+v矩形框选</p>
<p>[数字]G  跳到多少行<br>[数字]Enter  向下跳多少行</p>
<p>/[字符串]  查找文中该字符串<br>N向上查找<br>n向下查找</p>
<p>0 该行的第一个字符<br>$ 该行的最后一个字符</p>
<p>dd 删除该行<br>[数字]dd 删除往下[数字]行</p>
<p>yy 复制该行<br>[数字]yy 复制往下[数字]行</p>
<p>u 撤销<br>p 粘贴</p>
<p>vi -o 文件1 文件2多窗口打开<br>ctrl +w+w 窗口间切换</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://ideask.cf/2017/01/22/12864-udev-char-device/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Jason Lin">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Jason Lin">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Jason Lin" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/01/22/12864-udev-char-device/" itemprop="url">
                  LCD12864串口驱动udev
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-22T20:08:48+08:00">
                2017-01-22
              </time>
			  </span>
			
			<span>
    
			<span>更新于</span>
			<time>
			2017-01-22
			20:08:48
			</time>
			</span>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/设备驱动/" itemprop="url" rel="index">
                    <span itemprop="name">设备驱动</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/01/22/12864-udev-char-device/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/01/22/12864-udev-char-device/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="1、LCD12864串口驱动程序"><a href="#1、LCD12864串口驱动程序" class="headerlink" title="1、LCD12864串口驱动程序"></a>1、LCD12864串口驱动程序</h2><pre><code class="bash"><span class="comment">#include &lt;linux/module.h&gt;</span>
<span class="comment">#include &lt;linux/kernel.h&gt;</span>
<span class="comment">#include &lt;linux/types.h&gt;</span>
<span class="comment">#include &lt;linux/sched.h&gt;</span>
<span class="comment">#include &lt;linux/init.h&gt;</span>
<span class="comment">#include &lt;linux/fs.h&gt;</span>
<span class="comment">#include &lt;linux/ioctl.h&gt;</span>
<span class="comment">#include &lt;linux/delay.h&gt;</span>
<span class="comment">#include &lt;linux/bcd.h&gt;</span>
<span class="comment">#include &lt;linux/capability.h&gt;</span>
<span class="comment">#include &lt;linux/rtc.h&gt;</span>
<span class="comment">#include &lt;linux/cdev.h&gt;</span>
<span class="comment">#include &lt;linux/device.h&gt;</span>
<span class="comment">#include &lt;linux/gpio.h&gt;</span>
<span class="comment">#include &lt;linux/version.h&gt;</span>

<span class="comment">#include &lt;../arch/arm/mach-mx28/mx28_pins.h&gt;</span>

<span class="comment">#define DEVICE_NAME "LCD12864"</span>

<span class="comment">#define LCD_SID 57</span>
<span class="comment">#define LCD_CS 39</span>
<span class="comment">#define LCD_CLK 56</span>

<span class="comment">#define LCD_IOC_MAGIC 'L'</span>
<span class="comment">#define LCD_CMD _IO(LCD_IOC_MAGIC,0)</span>
<span class="comment">#define LCD_LINE _IO(LCD_IOC_MAGIC,1)</span>
<span class="comment">#define LCD_ROW _IO(LCD_IOC_MAGIC,2)</span>
<span class="comment">#define LCD_DATA _IO(LCD_IOC_MAGIC,3)</span>

<span class="comment">#define LCD_IOCTL_MAXNR 4</span>


<span class="comment">#define LCD_SID_H gpio_direction_output(LCD_SID,1);</span>
<span class="comment">#define LCD_SID_L gpio_direction_output(LCD_SID,0);</span>
<span class="comment">#define LCD_CS_H gpio_direction_output(LCD_CS,1);</span>
<span class="comment">#define LCD_CS_L gpio_direction_output(LCD_CS,0);</span>
<span class="comment">#define LCD_CLK_H gpio_direction_output(LCD_CLK,1);</span>
<span class="comment">#define LCD_CLK_L gpio_direction_output(LCD_CLK,0);</span>

static int major,minor;
struct cdev *lcd;
static dev_t devno;
static struct class *lcd_class;
static int lcd_open(struct inode *inode,struct file *filp);
static int lcd_release(struct inode *inode,struct file *filp);
static int lcd_ioctl(struct inode *inode,struct file *flip,unsigned int <span class="built_in">command</span>,unsigned long arg);
static int lcd_init(void);
static void lcd_exit(void);

struct file_operations lcd_fops ={
    .owner = THIS_MODULE,
    .open =lcd_open,
    .release = lcd_release,
<span class="comment">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2,6,36)</span>
    .unlocked_ioctl = lcd_ioctl,
<span class="comment">#else</span>
    .ioctl = lcd_ioctl
<span class="comment">#endif</span>
};

static void lcd_sendbyte(unsigned char byte)
{
    unsigned int i=0;
    <span class="keyword">for</span>(i=0;i&lt;8;i++)
    {
        LCD_CLK_L;
        udelay(1);
        <span class="keyword">if</span>(byte &amp; 0x80)
        {LCD_SID_H;}
        <span class="keyword">else</span>
        {LCD_SID_L;}
        LCD_CLK_H;
        udelay(1);
        LCD_CLK_L;
        udelay(1);
        byte = byte &lt;&lt; 1;
    }
}

static void lcd12864_write_cmd(unsigned char cmd)
{
    LCD_CS_H;
    lcd_sendbyte(0xf8);
    lcd_sendbyte(0xf0 &amp; cmd);
    lcd_sendbyte(0xf0 &amp; (cmd &lt;&lt; 4));
    LCD_CS_L;
    mdelay(10);
}

static void lcd12864_write_dat(unsigned char dat)
{

    LCD_CS_H;
    lcd_sendbyte(0xfa);
    lcd_sendbyte(0xf0 &amp; dat);
    lcd_sendbyte(0xf0 &amp; (dat &lt;&lt; 4));
    LCD_CS_L;
    mdelay(10);
}
static void lcd12864_init(void)
{
    lcd12864_write_cmd(0x30);
    lcd12864_write_cmd(0x02);
    lcd12864_write_cmd(0x06);
    lcd12864_write_cmd(0x0c);
    lcd12864_write_cmd(0x01);
    lcd12864_write_cmd(0x80);

}
static void lcd12864_clean(void)
{
    lcd12864_write_cmd(0x01);
}
static void lcd_string(unsigned char x,unsigned char y,unsigned char *String)
{
    <span class="keyword">if</span>((x &lt; 8)&amp;&amp;(y &lt; 4))
    {
        switch(y)
        {
            <span class="keyword">case</span> 0:
                lcd12864_write_cmd(0x80|0x00|x);
                <span class="built_in">break</span>;
            <span class="keyword">case</span> 1:
                lcd12864_write_cmd(0x80|0x10|x);
                <span class="built_in">break</span>;
            <span class="keyword">case</span> 2:
                lcd12864_write_cmd(0x80|0x08|x);
                <span class="built_in">break</span>;
            <span class="keyword">case</span> 3:
                lcd12864_write_cmd(0x80|0x18|x);
                <span class="built_in">break</span>;
        }
        <span class="keyword">while</span>(*String !=<span class="string">'\0'</span>)
        {
            lcd12864_write_dat(*String);
            mdelay(50);
            String++;
        }
    }

}    
static int lcd_open(struct inode *inode,struct file *file)
{
    try_module_get(THIS_MODULE);
    lcd12864_init();//init lcd12864 cmd 
    //init lcd12864 background
    lcd_string(0,0,<span class="string">"Linux Chardev"</span>);
    lcd_string(0,1,<span class="string">"LCD12864 Device"</span>);
    lcd_string(0,2,<span class="string">"Initialization"</span>);
    lcd_string(0,3,<span class="string">"Author:Jason"</span>);
    <span class="built_in">return</span> 0;
}
static int lcd_release(struct inode *inode,struct file *file)
{
    module_put(THIS_MODULE);
    lcd12864_clean();//close lcd12864 background
    lcd_string(0,0,<span class="string">"LCD12864 Device"</span>);
    lcd_string(0,1,<span class="string">"Already"</span>);
    lcd_string(0,2,<span class="string">"Closed"</span>);
    <span class="built_in">return</span> 0;
}


<span class="comment">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2,6,36)</span>
int lcd_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
<span class="comment">#else</span>
static int lcd_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg)
<span class="comment">#endif</span>
{
    <span class="keyword">if</span>(_IOC_TYPE(cmd) != LCD_IOC_MAGIC)
    {
        <span class="built_in">return</span> -ENOTTY;
    }
    <span class="keyword">if</span>(_IOC_NR(cmd) &gt; LCD_IOCTL_MAXNR)
    {
        <span class="built_in">return</span> -ENOTTY;
    }

    switch(cmd)
    {
        <span class="keyword">case</span> LCD_LINE:  //待开发
                <span class="built_in">break</span>;
        <span class="keyword">case</span> LCD_ROW:   //待开发
                <span class="built_in">break</span>;
        <span class="keyword">case</span> LCD_CMD:   //待开发
                <span class="built_in">break</span>;
        <span class="keyword">case</span> LCD_DATA:  //待开发
                <span class="built_in">break</span>;
    }
    <span class="built_in">return</span> 0;


}
static int __init lcd_init(void)
{
    int ret=0;

    gpio_free(LCD_SID);
    gpio_free(LCD_CS);
    gpio_free(LCD_CLK);
    ret += gpio_request(LCD_SID,<span class="string">"SID"</span>);
    ret += gpio_request(LCD_CS,<span class="string">"CS"</span>);
    ret += gpio_request(LCD_CLK,<span class="string">"CLK"</span>);
    <span class="keyword">if</span>(ret)
    {
        printk(<span class="string">"request gpio failed "</span>);
        <span class="built_in">return</span> -1;
    }
    ret = 0;
    ret = alloc_chrdev_region(&amp;devno,minor,1,<span class="string">"LCD12864"</span>);
    major = MAJOR(devno);
    <span class="keyword">if</span>(ret &lt; 0)
    {
        printk(KERN_ERR<span class="string">"cannot get major %d\n"</span>,major);
        <span class="built_in">return</span> -1;
    }
    lcd = cdev_alloc();
    <span class="keyword">if</span>(lcd !=NULL)
    {
        cdev_init(lcd,&amp;lcd_fops);
        lcd-&gt;owner = THIS_MODULE;
        <span class="keyword">if</span>(cdev_add(lcd,devno,1) != 0)
        {
            printk(KERN_ERR<span class="string">"add cdev error! \n"</span>);
            goto error;
        }
    }    
    <span class="keyword">else</span>
    {
        printk(KERN_ERR<span class="string">"cdev_alloc error! \n"</span>);
        <span class="built_in">return</span> -1;
    }

    lcd_class = class_create(THIS_MODULE,<span class="string">"lcd_class"</span>);
    <span class="keyword">if</span>(IS_ERR(lcd_class))
    {
        printk(KERN_INFO<span class="string">"create class error!\n"</span>);
        <span class="built_in">return</span> -1;
    }
    device_create(lcd_class,NULL,devno,NULL,<span class="string">"lcd12864"</span>);
    <span class="built_in">return</span> 0;
error:
    unregister_chrdev_region(devno,1);
    <span class="built_in">return</span> ret;

}
static void __exit lcd_exit(void)
{
    cdev_del(lcd);
    unregister_chrdev_region(devno,1);
    device_destroy(lcd_class,devno);
    class_destroy(lcd_class);
}

module_init(lcd_init);
module_exit(lcd_exit);

MODULE_LICENSE(<span class="string">"GPL"</span>);
MODULE_AUTHOR(<span class="string">"ideask,ideask@ideask.cf"</span>);
</code></pre>
<h2 id="2、Makefile"><a href="#2、Makefile" class="headerlink" title="2、Makefile"></a>2、Makefile</h2><pre><code class="bash">CC = arm-fsl-linux-gnueabi-gcc

ifneq ($(KERNELRELEASE),)
obj-m := lcd.o

PWD :=$(shell <span class="built_in">pwd</span>)
KVER :=$(shell uname -r)
KDIR :=/root/linux-2.6.35.3

all:
    $(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
    rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions
endif
</code></pre>
<h2 id="3、测试程序"><a href="#3、测试程序" class="headerlink" title="3、测试程序"></a>3、测试程序</h2><pre><code class="bash"><span class="comment">#include &lt;stdio.h&gt;</span>
<span class="comment">#include &lt;stdlib.h&gt;</span>
<span class="comment">#include &lt;unistd.h&gt;</span>
<span class="comment">#include &lt;sys/ioctl.h&gt;</span>
<span class="comment">#include &lt;errno.h&gt;</span>
<span class="comment">#include &lt;fcntl.h&gt;</span>


<span class="comment">#define DEV_NAME "/dev/lcd12864"</span>

int main(int argc, char *argv[])
{
    int i;
    int fd = 0;
    fd = open(DEV_NAME,O_RDONLY);
    <span class="keyword">if</span>(fd &lt; 0)
    {
        perror(<span class="string">"Open "</span>DEV_NAME<span class="string">"Failed!\n"</span>);
        <span class="built_in">return</span> -1;
    }
    //close(fd);
    <span class="keyword">while</span>(1);
    <span class="built_in">return</span> 0;
}
</code></pre>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>


    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a>
  </nav>


          
          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="Jason Lin" />
          <p class="site-author-name" itemprop="name">Jason Lin</p>
          <p class="site-description motion-element" itemprop="description">embedded system engineer</p>
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">9</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">9</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/ideask" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/ideask" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/ideask" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://douban.com/people/ideask" target="_blank" title="豆瓣">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  豆瓣
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/ideask" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jyu.edu.cn/" title="嘉应大学" target="_blank">嘉应大学</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jason Lin</span>
</div>



        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"ideask"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  












  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  
  

  


</body>
</html>
